gpt4 book ai didi

java - FirebaseInitProvider。找不到资源

转载 作者:行者123 更新时间:2023-12-01 22:27:14 33 4
gpt4 key购买 nike

我已经在应用程序中使用 Google Firebase 一段时间了,我正在进行一些维护和一些更新,但我不断收到:

Unable to get provider com.google.firebase.provider.FirebaseInitProvider

每当我启动应用程序时都会发生这种情况。我已经尝试启用 MultiDex和我的applicationId自从我开始使用 FCM 以来就已经设定了。我只是不知道它可能是什么。

任何帮助将不胜感激。

build.gradle(应用程序):

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.vivatrucking.drivershub"
multiDexEnabled true
minSdkVersion 15
targetSdkVersion 27
versionCode 2
versionName "1.0.1"
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 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
// android
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.volley:volley:1.0.0'
// google
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
//external libs
implementation 'com.github.devlight:infinitecycleviewpager:1.0.2'
}
apply plugin: 'com.google.gms.google-services'

完整堆栈跟踪:

05-08 15:03:31.400 30530-30530/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.vivatrucking.drivershub, PID: 30530 java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f0c002a at android.app.ActivityThread.installProvider(ActivityThread.java:6575) at android.app.ActivityThread.installContentProviders(ActivityThread.java:6127) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6037) at android.app.ActivityThread.-wrap1(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f0c002a at android.content.res.ResourcesImpl.getResourcePackageName(ResourcesImpl.java:253) at android.content.res.Resources.getResourcePackageName(Resources.java:1963) at com.google.android.gms.common.internal.StringResourceValueReader.(Unknown Source:16) at com.google.firebase.FirebaseOptions.fromResource(Unknown Source:2) at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:19) at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source:4) at android.content.ContentProvider.attachInfo(ContentProvider.java:1925) at android.content.ContentProvider.attachInfo(ContentProvider.java:1900) at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:23) at android.app.ActivityThread.installProvider(ActivityThread.java:6572) at android.app.ActivityThread.installContentProviders(ActivityThread.java:6127)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6037)  at android.app.ActivityThread.-wrap1(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6938)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

最佳答案

firebase-common 在 FirebaseApp.initializeApp(Context) 中查找特定的字符串资源“google_app_id”,在我的例子中该资源似乎不存在。

(com.google.firebase:firebase-common@@16.0.4:301)
StringResourceValueReader reader = new StringResourceValueReader(context);
String applicationId = reader.getString("google_app_id");

我想这应该由 google-services.json 填充。目前不确定解决方案。

关于java - FirebaseInitProvider。找不到资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50235765/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com