Dependancy error when integrating android studio p

2019-01-05 06:21发布

I'm developing an app in Kotlin and keep getting the error:

Failed to resolve: firebase-auth-15.0.0`

when trying to sync gradle. I'm trying to implement a google sign in feature.

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "nus.is3261.kotlinapp"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'

}

I have tried to follow the solution on stack overflow here, but I am left with this warning after syncing gradle Warning: The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended.

4条回答
Anthone
2楼-- · 2019-01-05 06:54

You are getting the following error:

Failed to resolve: firebase-auth-15.0.0

Because you are using a wrong dependency in your code. To solve this, please change the following line of code:

implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'

to

implementation 'com.google.firebase:firebase-auth:16.0.5'

Because such a version 16.0.1:15.0.0 does not exist.

Please also add the following dependency which is now mandatory:

implementation 'com.google.firebase:firebase-core:16.0.4'

Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.

In your top level build.gradle file please be sure to have the latest version of Google Service plugin:

classpath 'com.google.gms:google-services:4.1.0'
查看更多
地球回转人心会变
3楼-- · 2019-01-05 07:03

Replace implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'

By implementation 'com.google.firebase:firebase-auth:16.0.4'

Also add Firebase Core dependency implementation 'com.google.firebase:firebase-core:16.0.4'

Move your apply plugin: 'com.google.gms.google-services' to bottom of build file

查看更多
叼着烟拽天下
4楼-- · 2019-01-05 07:04

Remove

  implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'

add

 implementation 'com.google.firebase:firebase-database:16.0.1'
查看更多
时光不老,我们不散
5楼-- · 2019-01-05 07:05

If I make this the "add firebase authentication..." dissapear. You know... in android studio, the firebase assistant menu gives a quickly way to set firebase services. When click on "Add Firebase Authentication to your app" button, android says:

app/build.gradle

build.gradle will include these new dependencies:


compile 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
ACCEPT CHANGES? -> YESSSS

and then the sync fail. If I replace this with:

implementation 'com.google.firebase:firebase-auth:16.0.4'

firebase will not add to my app.

查看更多
登录 后发表回答