![](/img/trans.png)
[英]java.lang.NoSuchMethodError: No virtual method setTokenProvider(Lcom/google/firebase/internal/InternalTokenProvider;)
[英]I am getting the following error during runtime when running my app: java.lang.NoSuchMethodError: No virtual method setTokenProvider
在 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 上只找到了一篇关于此错误的其他帖子,并且提供的唯一解决方案对我不起作用。 网上似乎没有太多关于这个特定错误的信息,所以我来到这里急需帮助。 非常感谢所有回复:)
附注。 我对使用 Android Studio 还是很陌生
可能是因为您使用的是旧的Firebase身份验证和最新的Firebase存储以及Firebase 发行说明提供的详细信息:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.