【发布时间】:2018-07-12 11:22:38
【问题描述】:
我尝试测试 Google 地图并创建了一个新项目,从 API 控制台获取了 API 密钥。一切正常,没有问题。但是,当我尝试将 Google Maps 活动添加到工作项目中时,通过将此活动作为午餐者,通过上述步骤,现在我收到以下错误:
Google Maps Android API:授权失败。请参见 https://developers.google.com/maps/documentation/android-api/start 为 如何正确设置地图。 E/Google 地图 Android API:在 谷歌开发者控制台 (https://console.developers.google.com) 确保启用了“Google Maps Android API v2”。确保这件事 存在以下 Android 密钥: API 密钥: AIzaSyA5iBkfmlihtkh2Xc6T61v109eFJ3OGZrE Android 应用程序 (;):
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ganz.afex_with_default_navigation">
<!--
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" />
<application
android:name=".AfexApp"
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">
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name">
<!--
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
-->
</activity>
<activity
android:name=".activities.LoginActivity"
android:label="Tizimga kirish" />
<activity
android:name=".activities.RegistrationActivity"
android:label="Ro'yxatdan o'tish" />
<activity android:name=".activities.Tovar_description_Activity" />
<activity android:name=".activities.OmborActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name=".models.Switch_Mode" />
<activity android:name=".activities.SettingActivity" />
<activity
android:name=".AddressActivity"
android:label="@string/title_activity_address"
android:theme="@style/AppTheme" />
<activity android:name=".AddressAddingActivity" />
<!--
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=".activities.GoogleMapActivity"
android:label="@string/title_activity_google_map">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
【问题讨论】:
-
@tahsinRupam 谢谢,但我已经阅读并完成了所有步骤。它没有帮助我
-
仔细检查 Android 应用对 API 密钥的限制。包名和SHA1是否正确?
-
@xomena 一切都正确
标签: java android google-maps