FirebaseInitProvider获取失败求助:应用启动时资源缺失报错
Hey there! Let’s dig into this FirebaseInitProvider error you’re hitting post-maintenance. Since you’ve already checked MultiDex and applicationId, let’s go through some other targeted fixes that might resolve this:
Align all Firebase dependency versions
Mixed versions of Firebase libraries are a frequent culprit for this error. Ensure every Firebase-related dependency (likefirebase-core,firebase-messaging) uses the same version. For easier management, use Firebase's BOM to auto-sync versions:implementation platform('com.google.firebase:firebase-bom:32.7.0') // Use the latest stable version implementation 'com.google.firebase:firebase-core' implementation 'com.google.firebase:firebase-messaging'Double-check MultiDex setup completeness
Even if you enabled MultiDex, small configuration gaps can cause issues:- Confirm
multiDexEnabled trueis in yourdefaultConfigblock in app-levelbuild.gradle - If your
minSdkVersionis below 21, add the MultiDex dependency:implementation 'androidx.multidex:multidex:2.0.1' - If you have a custom Application class, either extend
MultiDexApplicationor add this override:@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } - Don’t forget to reference this custom class in your
AndroidManifest.xml
- Confirm
Wipe caches and rebuild from scratch
Post-maintenance cache conflicts are common. Try these steps:- Run
Build > Clean ProjectthenBuild > Rebuild Projectin Android Studio - Go to
File > Invalidate Caches...and select "Invalidate and Restart" - Delete the
.gradlefolder at your project root and thebuildfolder in your app module, then re-build
- Run
Validate Firebase configuration files
Make sure yourgoogle-services.jsonis in theapp/src/maindirectory and matches your Firebase project’s current settings (especiallypackage_nameand client IDs). If you updated your Firebase project recently, re-download this file and replace the old one. Also confirm the Google Services plugin is applied correctly:- In your project-level
build.gradle:dependencies { classpath 'com.google.gms:google-services:4.4.0' // Latest stable version } - Add
apply plugin: 'com.google.gms.google-services'at the end of your app-levelbuild.gradle
- In your project-level
Fix ProGuard/R8 obfuscation issues
If you’re using obfuscation, Firebase classes might be getting stripped. Add these rules to yourproguard-rules.pro:-keep class com.google.firebase.provider.FirebaseInitProvider { *; } -keep class com.google.firebase.** { *; } -keep class com.google.android.gms.** { *; }You can also temporarily disable obfuscation to test if this is the root cause.
Verify Manifest entries
Check if the FirebaseInitProvider is present in your merged Manifest (found atapp/build/intermediates/manifests/full/debug/AndroidManifest.xml). It should look like this:<provider android:name="com.google.firebase.provider.FirebaseInitProvider" android:authorities="${applicationId}.firebaseinitprovider" android:exported="false" android:initOrder="100" />If it’s missing, try re-adding your Firebase dependencies or manually inserting the entry.
内容的提问来源于stack exchange,提问作者Mwikala Kangwa

