在Android Studio Emulator上运行谷歌地图活动时出错



更新2:

我从更改了build.gradle(模块:应用程序)的行

编译'com.google.android.gms:play services:8.1.0'

收件人:

编译com.google.android.gms:play服务地图:8.3.0'

现在我得到错误:

'W/GooglePlayServicesUtil: Google Play services out of date.  Requires 8298000 but found 8185470'

模拟器还有一个按钮,屏幕上现在显示"更新",并显示"除非你更新Google Play服务,否则XXX不会运行。"

更新:

我注意到错误行:

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:30C:8B:26:D1:7F:45:52:E5:FB:01:A3:00:8E:E2

在google_maps_api.xml上,上面写着:

您还可以使用以下行将凭据添加到现有密钥:A8:79:D: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文件中,这就是我在谷歌中键入的SHA-1,以生成API密钥。

需要注意的是,我还尝试创建一个新密钥并输入该密钥。同样的问题。

原始帖子:

我正试图在安卓工作室(Nexus 5)的模拟器上进行谷歌地图活动,但每次我运行它时,它都会说我需要更新我的模拟器。我被告知要将我的build.gradle(模块:应用程序)从:更改为

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_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作为插件的限制。您只需要使用一个实际的设备就可以在这个时间点(2015年12月14日)使用谷歌播放服务的任何东西。

相关内容

  • 没有找到相关文章

最新更新