Google服务无法初始化,状态:10

时间:2016-10-23 02:39:58

标签: java android google-maps gradle

我目前在我正在开发的应用中使用Google地图,当我在手机上运行应用时,我的应用突然开始出现错误。

  

10-22 22:19:41.921 26626-26626 /? E / GMPM:GoogleService初始化失败,状态:10,缺少预期的资源:' R.string.google_app_id'用于初始化Google服务。可能的原因是缺少google-services.json或com.google.gms.google-services gradle插件。

我已经看过关于这个问题的类似帖子,我已经尝试了大部分解决方案。大多数人建议在{app} gradle的apply plugin: 'com.google.gms.google-services'末尾添加app.gradle以及classpath 'com.google.gms:google-services:3.0.0'

我'还在路径google-services.json

上添加了app/

这些解决方案都没有奏效,是否有人有另一种解决方法?

这些是我目前的分数

// Top-level build file where you can add configuration options common to              all sub-projects/modules.

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.2'




    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
   }
 }

 allprojects {
   repositories {
    jcenter()
    }
  }

 task clean(type: Delete) {
   delete rootProject.buildDir
 }

应用专用gradle

 apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.josebernhardt.rpvc_"
    minSdkVersion 17
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),    'proguard-rules.pro'
       }
    }
 }

   dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
  }

1 个答案:

答案 0 :(得分:0)

ensure that your device have the Google Play Services APK

  

Google Play services overview所述,Google Play通过Google Play商店应用为Android 2.3及更高版本的用户提供服务更新。但是,更新可能无法立即覆盖所有用户,因此您的应用应在尝试执行API事务之前验证可用版本。

正如documentation中所述,

  

注意:由于很难预测每台设备的状态,在访问Google Play服务功能之前,您必须始终检查兼容的Google Play服务。

此外,您可能还想在此SO post中尝试使用建议的解决方案,其中从play-services:8.4.0更新为play-services:9.2.0解决了问题。

希望有所帮助!

相关问题