将这些依赖项用于项目构建.格拉德尔
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
并将其放在应用程序级构建的末尾.gradle文件(在依赖项之后).
apply plugin: 'com.google.gms.google-services'
我不知道为什么把这个放在末尾(而不是在开头)可以解决这个错误.
EDIT 5/1/2016个
好的…所以我想结束你们在我的解决方案中遇到的所有问题
这是我最后一个应用程序级别的Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "your-app-name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.6@aar'
}
apply plugin: 'com.google.gms.google-services'
这是我的最后一个项目级别gradle
// 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.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
将其与您自己的gradle文件进行比较,并添加或修改与我所写内容不同的任何值.