由于在新笔记本电脑上升级到Android Studio 2.1.2,Google Map无法正常工作

问题描述:

我最近将笔记本电脑从一台笔记本电脑转移到另一台笔记本电脑上。 我安装了最新版本的Android工作室,这是2.1.2 我的旧笔记本电脑正在运行版本1.5.1由于在新笔记本电脑上升级到Android Studio 2.1.2,Google Map无法正常工作

导入gradle.build到新版本的新的笔记本电脑后,我的MapsActivity不再工作,而它以前工作完美。 因此,我知道问题不在代码中,或者来自Google的API密钥。

我想我已经从SDK管理器下载了所有相同的软件包。

当它最初被“重建”时,它提示有一个片段“问题”,我通过下载Google Play服务解决了这个问题,但现在它什么也没有显示。

任何帮助或建议非常欢迎。 当我在AVD模拟器中运行应用程序时,出现以下消息。

06-09 18:43:17.909 2971-2971/com.example.grant.fbcc I/art: Not late-enabling -Xcheck:jni (already on) 
06-09 18:43:18.016 2971-2971/com.example.grant.fbcc W/System: ClassLoader referenced unknown path: /data/app/com.example.grant.fbcc-1/lib/x86 
06-09 18:43:28.469 2971-2971/com.example.grant.fbcc W/System: ClassLoader referenced unknown path: /data/app/com.example.grant.fbcc-1/lib/x86 
06-09 18:43:28.597 2971-2971/com.example.grant.fbcc W/art: Verification of void com.google.android.gms.measurement.internal.zzw.<init>(com.google.android.gms.measurement.internal.zzaa) took 101.927ms 
06-09 18:43:28.679 2971-2971/com.example.grant.fbcc I/GMPM: App measurement is starting up, version: 8487 
06-09 18:43:28.679 2971-2971/com.example.grant.fbcc I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE 
06-09 18:43:28.717 2971-2971/com.example.grant.fbcc E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin. 
06-09 18:43:28.717 2971-2971/com.example.grant.fbcc E/GMPM: Scheduler not set. Not logging error/warn. 
06-09 18:43:28.782 2971-3094/com.example.grant.fbcc E/GMPM: Uploading is not possible. App measurement disabled 
06-09 18:43:29.031 2971-2971/com.example.grant.fbcc W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 
06-09 18:43:29.162 2971-3105/com.example.grant.fbcc D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true 

                    [ 06-09 18:43:29.168 2971: 2971 D/   ] 
                    HostConnection::get() New Host Connection established 0xa15a2330, tid 2971 


                    [ 06-09 18:43:29.211 2971: 3105 D/   ] 
                    HostConnection::get() New Host Connection established 0xa15a20f0, tid 3105 
06-09 18:43:29.219 2971-3105/com.example.grant.fbcc I/OpenGLRenderer: Initialized EGL, version 1.4 
06-09 18:43:39.145 2971-3094/com.example.grant.fbcc I/GMPM: Tag Manager is not found and thus will not be used 
06-09 18:45:48.613 2971-2977/com.example.grant.fbcc W/art: Suspending all threads took: 9.378ms 

您是否更新了Developer Console的凭据? 如果您使用的是新笔记本电脑,则它具有不同的调试密钥,这不适用于您现有的API密钥。

转到Developer Console> Credentials,使用更新后的SHA-1创建一个新的Android密钥,然后您应该恢复正常业务。 (DevCon网站有关于如何根据需要将SHA-1从您的新笔记本电脑中取出的说明)

+1

Tha t工作了一种享受,非常感谢。我从来没有想过,新构建需要一个新的API密钥/ SHA-1。 –

除了上面的答案,这是原始问题确实需要的,我想添加以下要求我发现在我的重新构建被要求: -

在下面的链接,一些编译语句, https://developers.google.com/android/guides/setup

其中我需要添加下面一行到应用程序建立gradle这个

compile 'com.google.android.gms:play-services-maps:9.2.0'