我已经看到很多关于这个话题的其他问题,但是他们都处理了我认为与我的情况无关的事情,所以我要做一个新问题。
在我的Android应用程序中,我希望将firebase用作我的数据库。但是,将google服务json文件复制到我的应用程序后,文件夹,并在我的' build.gradle'中添加必要的依赖项。文件,它提供了一个错误,说了带有ID" com.google.gms.google-services"的插件找不到'。我将包含build.gradle的代码,如果我在某个地方犯了错误,请告诉我!
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.xlr8.jackson.doctrineoropinion"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
classpath 'com.google.gms:google-services:3.0.0'
}
buildscript {
dependencies {
}
}
备注:
我尝试了几个选项,例如:
classpath 'com.google.gms:google-services:3.0.0'
移至buildscript / dependencies中的底部classpath 'com.google.gms:google-services:3.0.0'
更改为classpath 'com.google.gms:google-services:1.3.0-beta1'
提前致谢!
答案 0 :(得分:0)
首先你做错了,不能添加google play服务。你需要先在项目级别构建gradle中编译google play服务
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
然后在app level build.gradle中添加您需要的库,如下所示
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.firebase:firebase-messaging:9.6.0'