我正在关注此Udacity tutorial以获取用户Lat / Long位置值并在TextView中显示这些值。我正在努力启用适用于Android的Maps API,但在模拟器(带有Google API的Nexus 6)上运行时收到错误消息: getGoogleAppId失败,状态为:10,但我不确定如何解决此错误。
我已按照Signup and API Keys的Google文档中的步骤操作,这是应用代码。
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trishwhetzel.googlelocationservices" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="MY-API-KEY"/>
<activity
android:name=".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>
</application>
</manifest>
我将调试指纹证书和应用包名称添加到Google开发者控制台中的项目中,该项目启用了Google Maps Android API以生成Android API密钥。
我根据Google文档here创建了一个google-services.json文件,其结果文件如下,并将其添加到/ app。
谷歌-services.json
{
"project_info": {
"project_id": "plwjava",
"project_number": "339950946077",
"name": "plwjava"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:339950946077:android:27d689d63f1b7a06",
"client_id": "android:com.google.samples.quickstart.signin",
"client_type": 1,
"android_client_info": {
"package_name": "com.google.samples.quickstart.signin"
}
},
"oauth_client": [],
"api_key": [],
"services": {
"analytics_service": {
"status": 1
},
"cloud_messaging_service": {
"status": 2,
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 1
},
"ads_service": {
"status": 1
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:339950946077:android:e6522183029b3f29",
"client_id": "android:com.google.android.gms",
"client_type": 1,
"android_client_info": {
"package_name": "com.google.android.gms"
}
},
"oauth_client": [],
"api_key": [],
"services": {
"analytics_service": {
"status": 1
},
"cloud_messaging_service": {
"status": 2,
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 1
},
"ads_service": {
"status": 1
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:339950946077:android:11a88aaa174bec42",
"client_id": "android:com.google.android.gms.maps",
"client_type": 1,
"android_client_info": {
"package_name": "com.google.android.gms.maps"
}
},
"oauth_client": [],
"api_key": [],
"services": {
"analytics_service": {
"status": 1
},
"cloud_messaging_service": {
"status": 2,
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 1
},
"ads_service": {
"status": 1
}
}
}
],
"client_info": [],
"ARTIFACT_VERSION": "1"
}
日志:
12-26 15:59:57.112 2485-2485/? I/art: Not late-enabling -Xcheck:jni (already on)
12-26 15:59:57.206 2485-2485/com.trishwhetzel.googlelocationservices W/System: ClassLoader referenced unknown path: /data/app/com.trishwhetzel.googlelocationservices-2/lib/x86
12-26 15:59:57.325 2485-2505/com.trishwhetzel.googlelocationservices I/GMPM: App measurement is starting up
12-26 15:59:57.333 2485-2505/com.trishwhetzel.googlelocationservices E/GMPM: getGoogleAppId failed with status: 10
12-26 15:59:57.364 2485-2505/com.trishwhetzel.googlelocationservices E/GMPM: Uploading is not possible. App measurement disabled
12-26 15:59:57.549 2485-2510/com.trishwhetzel.googlelocationservices D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-26 15:59:57.769 2485-2510/com.trishwhetzel.googlelocationservices I/OpenGLRenderer: Initialized EGL, version 1.4
12-26 15:59:57.837 2485-2510/com.trishwhetzel.googlelocationservices W/EGL_emulation: eglSurfaceAttrib not implemented
12-26 15:59:57.837 2485-2510/com.trishwhetzel.googlelocationservices W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xad760360, error=EGL_SUCCESS