【发布时间】:2017-07-16 06:46:30
【问题描述】:
我正在将 Google 地图添加到片段中 像这样使用 MapView:
public HotspotPageFragment() {
// Required empty public constructor
}
private void initGoogleMap(Bundle savedInstanceState) {
mapView = (MapView) parentView.findViewById(R.id.mapView_hotspot);
mapView.onCreate(savedInstanceState);
mapView.onResume();
mapView.getMapAsync(this);
try {
MapsInitializer.initialize(context);
} catch (Exception e) {
e.printStackTrace();
}
}
这似乎适用于添加谷歌地图。
但现在我收到一条关于授权失败的错误消息
E/Google Maps Android API: Authorization failure.
Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: AIzaSyAMQNk********kCx8p-uz8******1t75s
Android Application (<cert_fingerprint>;<package_name>): 5A:A1:E4:**:07:BF:E2:**:A3:F0:B6:**:04:4E:0A:**:2A:B6:B4:6B;com.example.androidwork.foodsharing
我已检查 API 密钥是否正确... 我不知道如何解决它:(
这是我的清单:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- Google map -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
...
这就是结果
谢谢。
这表明我启用了它对吗?
【问题讨论】:
-
您启用了 Google Maps Android API v2" 吗?
-
.. 我很困惑在哪里启用?请告诉我>
-
好的,等我给你看
-
您找到解决方案了吗?我在一切正常的情况下都面临着类似的问题。清单 -> 使用 API 密钥显示权限和元数据,启用 google map API v2,在屏幕上显示地图,使用适当的密钥库
-
它也在使用我的临时不同的 API 密钥。为此,我一旦清除了缓存和数据。第二次卸载整个应用程序,然后重新安装。但还是一样
标签: java android google-maps-api-3 authorization android-mapview