在文件中添加Firebase数据库依赖项时出现以下错误:
Gradle文件代码在这里:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mymate.myownidea.fawad.my_mate"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.firebase:firebase-database:11.8.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:27.1.0'
compile 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.2'
compile 'com.google.firebase:firebase-auth:16.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
要解决此问题,请更改以下代码行:
implementation 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-core:16.0.0'
到
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
并删除以下代码行:
compile 'com.google.firebase:firebase-auth:16.0.2'
也不要忘记在顶级build.gradle
文件中添加最新版本的Google Play服务:
classpath 'com.google.gms:google-services:4.0.1'
请参阅here更多信息。
答案 1 :(得分:0)
执行以下操作:
将com.google.gms:google-services
从3.1.1
更新为3.2.0
:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
将compile
更改为implementation
:
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.2'