添加google-services.json后,我收到的错误如

时间:2016-03-21 12:28:50

标签: android android-studio google-play-services

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

这是我的项目gradle文件

// Top-level build file where you can add configuration options common to        all sub-projects/modules.
     apply plugin: 'maven-publish'
     apply plugin: "java"


     buildscript {
     repositories {
    jcenter()
   }
dependencies {

    classpath 'com.android.tools.build:gradle:2.1.0-alpha3'
    classpath 'com.google.gms:google-services:2.0.0-alpha5'

}

}

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

   task sourceJar(type: Jar) {
     from sourceSets.main.allJava
     classifier "sources"
   }

  publishing {
       publications {
    mavenJava(MavenPublication) {
        from components.java
        artifact sourceJar
        pom.withXml {
            asNode().appendNode('description', 'A demonstration of Maven  POM customization')
        }
    }
}
    }

这是我的app.gardle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
 android {
    compileSdkVersion 23
     buildToolsVersion '23.0.2'

defaultConfig {

    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
    generatedDensities = []
}

aaptOptions {
    additionalParameters "--no-version-vectors"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dexOptions {
    preDexLibraries = false
    javaMaxHeapSize "4g"
}
  }

 dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
      compile files('libs/universal-image-loader-1.9.5.jar')
      compile project(':databaseAutoCompleteLibrary')
    compile 'com.android.support:support-v4:23.2.0'
   compile 'com.android.support:gridlayout-v7:23.2.0'
    compile project(':MPChartLib')
    compile project(':filechooserlibrary')
   compile 'com.android.support:design:23.2.0'
   compile 'com.android.support:support-v13:23.2.0'
   compile 'com.android.support:appcompat-v7:23.2.0'
   compile project(':Volley')
   compile 'com.google.code.gson:gson:2.4'
   compile 'com.loopj.android:android-async-http:1.4.9'
   compile 'com.jakewharton:butterknife:7.0.1'
   compile 'com.baoyz.swipemenulistview:library:1.3.0'
   compile 'milyn:opencsv:1.6'
   compile 'de.hdodenhof:circleimageview:2.0.0'
   compile 'com.squareup.picasso:picasso:2.5.2'

   compile 'com.google.android.gms:play-services:8.3.0'
   compile 'com.android.support:multidex:1.0.1'

  }

1 个答案:

答案 0 :(得分:2)

将此应用于您的app build.gradle文件

apply plugin: 'com.google.gms.google-services'

dependencies {
    compile 'com.google.android.gms:play-services:8.3.0'
  }

在你的项目build.gradle define

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.google.gms:google-services:1.5.0-beta2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}