在 Android Studio 模拟器上出现错误 运行 Google 映射 Activity
Error Running Google Maps Activity on Android Studio Emulator
更新二:
我将 build.gradle(模块:app)的行从
更改为
compile 'com.google.android.gms:play-services:8.1.0'
收件人:
compile 'com.google.android.gms:play-services-maps:8.3.0'
现在我得到错误:
'W/GooglePlayServicesUtil: Google Play services out of date. Requires 8298000 but found 8185470'
模拟器还有一个按钮,现在在屏幕上显示 "Update" 并显示 "XXX won't run unless you update Google Play services."
更新:
我注意到错误行:
Android Application (<cert_fingerprint>;<package_name>): 63:99:6C:AC:5A:45:3C:8B:26:D1:7F:45:52:E5:FB:01:A3:00:8E:E2;com.lightningboltstudios.audubontrailmap
SHA-1 证书指纹列为:
63:99:6C:AC:5A:45:3C:8B:26:D1:7F:45:52:E5:FB:01:A3:00:8E:E2
在 google_maps_api.xml 上它说:
You can also add your credentials to an existing key, using this line:
A8:79:0D:B6:52:CC:C3:48:F8:E2:53:F4:7C:DB:F6:FF:90:AC:18:E0;com.lightningboltstudios.audubontrailmap
所以现在我迷路了。它几乎看起来像是在尝试使用具有不同 SHA-1 证书指纹的 API 密钥然后在 google_maps_api.xml 文件中,这就是我在 google 中输入的 SHA-1 到生成 API 密钥。
请注意,我还尝试创建一个新密钥并输入该密钥。同样的问题。
原文Post:
我正在尝试在 Android studio (Nexus 5) 的模拟器上制作 google 地图 activity,但每次我 运行 它,它会说我需要更新我的模拟器。
我被告知要将我的 build.gradle (Module:app) 更改为:
compile 'com.google.android.gms:play-services:8.3.0'
收件人:
compile 'com.google.android.gms:play-services:8.1.0'
然后我开始收到这个新错误:
E/b: Authentication failed on the server.
E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android/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: (redacted)
Android Application (<cert_fingerprint>;<package_name>): 63:99:6C:AC:5A:45:3C:8B:26:D1:7F:45:52:E5:FB:01:A3:00:8E:E2;com.lightningboltstudios.audubontrailmap
我的 activity 文件 activity_trail_map.xml 是:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.lightningboltstudios.audubontrailmap.TrailMapActivity" />
我的 TrailMapActivity java 文件是:
package com.lightningboltstudios.audubontrailmap;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class TrailMapActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_trail_map);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
我的 google_maps_api.xml 值文件是:
<resources>
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">(redacted)</string>
目前这是 Android Studio 模拟器和 Genymotion 作为插件的限制。您只需要使用实际设备即可在此时 (12/14/2015)
使用 google 播放服务
更新二:
我将 build.gradle(模块:app)的行从
更改为compile 'com.google.android.gms:play-services:8.1.0'
收件人:
compile 'com.google.android.gms:play-services-maps:8.3.0'
现在我得到错误:
'W/GooglePlayServicesUtil: Google Play services out of date. Requires 8298000 but found 8185470'
模拟器还有一个按钮,现在在屏幕上显示 "Update" 并显示 "XXX won't run unless you update Google Play services."
更新:
我注意到错误行:
Android Application (<cert_fingerprint>;<package_name>): 63:99:6C:AC:5A:45:3C:8B:26:D1:7F:45:52:E5:FB:01:A3:00:8E:E2;com.lightningboltstudios.audubontrailmap
SHA-1 证书指纹列为:
63:99:6C:AC:5A:45:3C:8B:26:D1:7F:45:52:E5:FB:01:A3:00:8E:E2
在 google_maps_api.xml 上它说:
You can also add your credentials to an existing key, using this line: A8:79:0D:B6:52:CC:C3:48:F8:E2:53:F4:7C:DB:F6:FF:90:AC:18:E0;com.lightningboltstudios.audubontrailmap
所以现在我迷路了。它几乎看起来像是在尝试使用具有不同 SHA-1 证书指纹的 API 密钥然后在 google_maps_api.xml 文件中,这就是我在 google 中输入的 SHA-1 到生成 API 密钥。
请注意,我还尝试创建一个新密钥并输入该密钥。同样的问题。
原文Post:
我正在尝试在 Android studio (Nexus 5) 的模拟器上制作 google 地图 activity,但每次我 运行 它,它会说我需要更新我的模拟器。 我被告知要将我的 build.gradle (Module:app) 更改为:
compile 'com.google.android.gms:play-services:8.3.0'
收件人:
compile 'com.google.android.gms:play-services:8.1.0'
然后我开始收到这个新错误:
E/b: Authentication failed on the server.
E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android/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: (redacted)
Android Application (<cert_fingerprint>;<package_name>): 63:99:6C:AC:5A:45:3C:8B:26:D1:7F:45:52:E5:FB:01:A3:00:8E:E2;com.lightningboltstudios.audubontrailmap
我的 activity 文件 activity_trail_map.xml 是:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.lightningboltstudios.audubontrailmap.TrailMapActivity" />
我的 TrailMapActivity java 文件是:
package com.lightningboltstudios.audubontrailmap;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class TrailMapActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_trail_map);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
我的 google_maps_api.xml 值文件是:
<resources>
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">(redacted)</string>
目前这是 Android Studio 模拟器和 Genymotion 作为插件的限制。您只需要使用实际设备即可在此时 (12/14/2015)
使用 google 播放服务