【问题标题】:I am getting the following error during runtime when running my app: java.lang.NoSuchMethodError: No virtual method setTokenProvider运行我的应用程序时,我在运行时收到以下错误:java.lang.NoSuchMethodError: No virtual method setTokenProvider
【发布时间】:2020-10-27 10:39:57
【问题描述】:

我在 Android Studio 的模拟器中运行我的应用时遇到此错误。应用编译成功。

java.lang.NoSuchMethodError: 类 Lcom/google/firebase/FirebaseApp 中没有虚拟方法 setTokenProvider(Lcom/google/firebase/internal/InternalTokenProvider;)V;或其超类(“com.google.firebase.FirebaseApp”的声明出现在 /data/app/~~_7zL9Id2RK7b6zEuTNlmiQ==/com.example.abc_supermarket-2V5eMXxz7SuahQK49NOpSw==/base.apk)

我的摇篮

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.abc_supermarket"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    implementation 'com.google.firebase:firebase-database:19.5.0'
    implementation 'com.google.firebase:firebase-storage:19.2.0'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'


// For Card view
    implementation 'androidx.cardview:cardview:1.0.0'

// Chart and graph library
    implementation 'com.github.blackfizz:eazegraph:1.2.5l@aar'
    implementation 'com.nineoldandroids:library:2.4.0'

    repositories {
        maven { url 'https://jitpack.io' }
    }

    dependencies {
        implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

    }

    android {
        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }
    }


}

该错误仅在我将 Firebase 存储添加到我的应用后才开始出现。我在 SO 上只找到了一篇关于此错误的帖子,并且提供的唯一解决方案对我不起作用。网上似乎没有太多关于这个特定错误的信息,所以我来到这里迫切需要帮助。非常感谢所有回复:)

PS。我对使用 Android Studio 还是很陌生

【问题讨论】:

    标签: java android firebase firebase-authentication


    【解决方案1】:

    可能是因为您使用的是旧的 firebase 身份验证和最新的 firebase 存储,Firebase release notes 提供了详细信息:

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

    此更新的重大更改:

    • 如果您使用 Firebase 身份验证,请更新到 firebase-auth v17.0.0 或更高版本,以确保功能与其他更新后的 Firebase 库保持一致。
    • 多个库将 minSdkVersion 更新到 API 级别 16 以与 Google Play 保持一致 服务分发政策。
    • 在您的项目级 build.gradle 文件中,确保在您的 buildscript 和 allprojects 部分中都包含 Google 的 Maven 存储库。

    只需将其更改为新版本的 firebase auth

    【讨论】:

      猜你喜欢
      • 2017-07-18
      • 2015-12-28
      • 1970-01-01
      • 2014-10-25
      • 2011-12-13
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      相关资源
      最近更新 更多