Java 错误:无法访问 InternalTokenProvider (Firebase/GooglePlayServices)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/56069259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:14:43  来源:igfitidea点击:

error: cannot access InternalTokenProvider (Firebase/GooglePlayServices)

javaandroidfirebasegoogle-play-servicesfirebaseui

提问by Jose Q

In my app where I use firebase, firebase-ui, google maps, among others, it worked perfectly. I want to update to the latest version of each library and install Firebase Performance.

在我使用 firebase、firebase-ui、谷歌地图等的应用程序中,它运行良好。我想更新到每个库的最新版本并安装 Firebase Performance。

The errorI get is:

我得到的错误是:

error: cannot access InternalTokenProvider
class file for com.google.firebase.internal.InternalTokenProvider not found

And when I click on this error it sends me to an Activity to this line:

当我单击此错误时,它会将我发送到此行的 Activity:

auth = FirebaseAuth.getInstance();

Here's my build.gradle:

这是我的 build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    signingConfigs {
        release {
            //signin things
        }
    }
    compileSdkVersion 28
    defaultConfig {

        applicationId "app.example.asd"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 22
        versionName "2"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        signingConfig signingConfigs.release
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'

    implementation 'com.google.firebase:firebase-perf:17.0.0'

    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.facebook.android:facebook-android-sdk:4.42.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation "com.google.firebase:firebase-auth:16.0.1"
    implementation 'com.firebaseui:firebase-ui:4.3.2'
    implementation 'com.facebook.android:facebook-login:4.42.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-places:16.1.0'

    implementation 'com.google.firebase:firebase-inappmessaging-display:17.1.1'

    implementation 'com.facebook.android:facebook-share:4.42.0'

    implementation 'com.android.volley:volley:1.1.1'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'

    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    //kt y rxjava
    implementation 'androidx.core:core-ktx:1.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
    //lib en kt
}

repositories {
    mavenCentral()
}
apply plugin: 'com.google.gms.google-services'

Can anyone detect where the problem is in my dependencies?Thank you

谁能检测到我的依赖项中的问题在哪里?谢谢

UPDATEWith Peter's help I was able to correct the error, changing from firebase-auth:16.0.1 to firebase-auth:17.0.0.

更新在彼得的帮助下,我能够纠正错误,从 firebase-auth:16.0.1 更改为 firebase-auth:17.0.0。

Now I'm getting another error when I install and open my app, this is it:

现在我在安装和打开我的应用程序时遇到另一个错误,就是这样:

java.lang.RuntimeException: Uncaught exception in Firebase Database runloop (3.0.0). Please report to [email protected]
        at com.google.firebase.database.android.AndroidPlatform.run(com.google.firebase:firebase-database@@16.0.5:98)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:7000)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListener;

The error appears the first time I use this line in my app:

我第一次在我的应用程序中使用此行时出现错误:

myRef = FirebaseDatabase.getInstance().getReference();

采纳答案by jkasnicki

It looks like you are pulling in com.google.firebase:firebase-database:16.0.5via the dependency on com.firebaseui:firebase-ui:4.3.2(https://github.com/firebase/FirebaseUI-Android/releases/tag/4.3.2)

看起来您是com.google.firebase:firebase-database:16.0.5通过对com.firebaseui:firebase-ui:4.3.2( https://github.com/firebase/FirebaseUI-Android/releases/tag/4.3.2)的依赖拉进来的

Try adding this to your build.gradle:

尝试将此添加到您的build.gradle

implementation 'com.google.firebase:firebase-database:17.0.0'

Also, generally check you are using the latest versions, which can be found at https://firebase.google.com/docs/android/setup#available-libraries

此外,通常检查您使用的是最新版本,可以在https://firebase.google.com/docs/android/setup#available-libraries找到

NOTE:This is based on the new error in your update after changing from firebase-auth:16.0.1 to firebase-auth:17.0.0

注意:这是基于从 firebase-auth:16.0.1 更改为 firebase-auth:17.0.0 后更新中的新错误

回答by Peter Haddad

Change this:

改变这个:

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

Into this:

进入这个:

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

回答by user3156040

Upgrade everything(Firebase Auth, Cloud, etc) to the latest versions by just hovering mouse over it.

只需将鼠标悬停在其上,即可将所有内容(Firebase 身份验证、云等)升级到最新版本。

回答by android studio

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

实现 'com.google.firebase:firebase-auth:16.0.5'

implementation 'com.google.firebase:firebase-database:17.0.0'

实现 'com.google.firebase:firebase-database:17.0.0'

回答by T Manojith

implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'

or:

或者:

implementation 'com.google.firebase:firebase-analytics:17.4.1'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.google.firebase:firebase-auth:19.3.1'

Sync to this version and see.
If not, upgrade the Firebase tools on Android Studio.

同步到此版本并查看。
如果没有,请升级 Android Studio 上的 Firebase 工具。