首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Android谷歌地图不显示地图

Android谷歌地图不显示地图
EN

Stack Overflow用户
提问于 2019-05-17 09:36:18
回答 1查看 2.3K关注 0票数 1

我正在尝试使用android中的google创建一个google地图活动。我生成了API密钥并将其粘贴到google_maps_api.xml`中。我的清单文件是:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.l5434.project">

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality.
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <permission android:name="com.example.l5434.project" android:protectionLevel="signature"/>


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file "res/values/google_maps_api.xml").
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/.
        -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name="pubsub.subscriber.MapsActivity"
            android:label="@string/title_activity_maps"></activity>
        <activity android:name="pubsub.subscriber.SubscriberActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我还在我的build.gradle中添加了依赖项build.gradle,但是它没有解决这个问题。当映射活动开始时,模拟器就是这样看的。

你知道怎么回事吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-17 09:52:45

此问题通常与用于签署清单的映射API密钥有关。看看this post和this one,它们描述了您正在经历的相同错误。在这两种情况下,这都是因为他们使用的API密钥是用错误的密钥库创建的。在Google控制台中创建API键时,需要确保使用调试keystore

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56191118

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文