Immediate Crash on app launch

When the app gets launched there is an immediate crash. It doesn’t get to any splash screen it crashes the second you open it. It looks like its related to firebase but I can’t identify the cause. I’m running the most up to date firebase plugins (12.1.0) previously I was running 10.5.0. I’m also using the google play games services plugin 0.11.01 which as far as I can tell is the most current version of that plugin also. I’m using Unity 2022.3.38f1 and targeting API 34. The app builds but crashes immediately upon launching.

FATAL EXCEPTION: main
Process: com.lazygoosegames.bulletblitz, PID: 31064
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions;
at com.google.firebase.provider.FirebaseInitProvider.checkContentProviderAuthority(FirebaseInitProvider.java:85)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:60)
at android.app.ActivityThread.installProvider(ActivityThread.java:8220)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7728)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7482)
at android.app.ActivityThread.access$1700(ActivityThread.java:310)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.common.internal.Preconditions
at com.google.firebase.provider.FirebaseInitProvider.checkContentProviderAuthority(FirebaseInitProvider.java:85) 
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:60) 
at android.app.ActivityThread.installProvider(ActivityThread.java:8220) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7728) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7482) 
at android.app.ActivityThread.access$1700(ActivityThread.java:310) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loopOnce(Looper.java:226) 
at android.os.Looper.loop(Looper.java:313) 
at android.app.ActivityThread.main(ActivityThread.java:8663) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) 

So as far as I can tell, the error is most likely due to missing dependencies. I’ve been trying to manually include the dependencies I find in the include .pom files but it just results in a similar NoClassDefFoundError but a different resolution instead.

This all started after I had a duplicate class error and it was suggested to use a custom main, base, and settings gradle template. Prior to doing that all resolved libraries sat within my Assets/Plugins/Android folder but now I don’t see any of those any more. I’m basically just chasing dependencies and nothing is working for me.

Is this possibly an issue with EDR4U? Is it no longer properly resolving the libraries? My guess is its based on the dependencies needed for play-services-base-18.5.0.

My duplicate classes post for reference:

EDIT: So I can confirm that my EDR4U is not resolving my libraries any more. I have gotten past the crash by manually including various libraries required by firebase. I’m still having to go through and manually include various libraries to get my game functional again but its definitely due to the libraries not being resolved.

I solved the crash and got my game working again. I had to manually include 7 different dependencies by downloading them from Maven Repository. The way to determine the needed dependencies for Firebase and Google Play Services plugins is to find them on that website and go down to the dependencies. My EDR4U was doing all of the androidx.core ones but was not resolving a handful of firebase and google play services dependencies. You can also find dependencies in the .pom files of whatever .aar you are including.

If you need to resolve the project again and want to try EDM4U please check out the troubleshooting guide and see if it allows it to resolve properly this time.

If not, please tell me how it doesn’t work and I will convey your feedback to the team.

Looking through the troubleshooting guide, I couldn’t see anything glaringly wrong with how I had mine set up but I’ll run you through how my set up was to see if there is something I’m doing wrong which could very well be the case.

The troubles started after I tried to target API 34 but the Unity version I was using at the time (2022.3.3f1) had a bug that prevented that from happening. I was advised by other staff that I needed to update my Unity version to the most current one to fix that which as of a week ago was 2022.3.38f1.

After upgrading my Unity version I started getting duplicate class errors when trying to build my game to Android. I made another post, linked in a comment above, and I was advised by one of the Unity staff members that:

If you’re using EDM4U, you need to enable gradle templates - main gradle template, settings gradle, gradle proprties, and force resolve again.

I followed this step and then I no longer received the duplicate class errors however I started receiving missing class errors for gpgs and firebase. I solved that error by reimporting my google play games services plugin and updating all of my firebase plugins to the most current versions.

It then let me build but then lead to the crash above. After some digging I found that it was due to some missing dependencies. EDR4U was resolving some libraries but not all of them and the resolved libraries were no longer showing in my Assets/Plugins/Android folder like they were before I enabled the custom templates. Below is the part of my build.gradle file showing what dependencies were resolved and which ones I had to resolve myself. After resolving these myself my game now builds and no longer crashes. According to my Assets folder I have EDR4U version 1.2.281 however my changelog for it only shows up to 1.2.169 so I’m not sure if something wasn’t updated fully. In the post linked above I have a picture of how my custom gradle templates are set up. If I can provide anymore info let me know.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
    implementation 'com.google.android.gms:play-services-base:18.5.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:17
    implementation 'com.google.firebase:firebase-analytics:22.0.2' // Assets/Firebase/Editor/StorageDependencies.xml:15
    implementation 'com.google.firebase:firebase-analytics-unity:12.1.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    implementation 'com.google.firebase:firebase-app-unity:12.1.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    implementation 'com.google.firebase:firebase-auth:23.0.0' // Assets/Firebase/Editor/AuthDependencies.xml:13
    implementation 'com.google.firebase:firebase-auth-unity:12.1.0' // Assets/Firebase/Editor/AuthDependencies.xml:20
    implementation 'com.google.firebase:firebase-common:21.0.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    implementation 'com.google.firebase:firebase-database:21.0.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:13
    implementation 'com.google.firebase:firebase-database-unity:12.1.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:22
    implementation 'com.google.firebase:firebase-firestore:25.0.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:13
    implementation 'com.google.firebase:firebase-firestore-unity:12.1.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:20
    implementation 'com.google.firebase:firebase-iid:21.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:17
    implementation 'com.google.firebase:firebase-messaging:24.0.0' // Assets/Firebase/Editor/MessagingDependencies.xml:13
    implementation 'com.google.firebase:firebase-messaging-unity:12.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:24
    implementation 'com.google.firebase:firebase-storage:21.0.0' // Assets/Firebase/Editor/StorageDependencies.xml:13
    implementation 'com.google.firebase:firebase-storage-unity:12.1.0' // Assets/Firebase/Editor/StorageDependencies.xml:20
    implementation 'com.google.flatbuffers:flatbuffers-java:1.12.0' // Assets/Firebase/Editor/MessagingDependencies.xml:19
    implementation 'com.google.games:gpgs-plugin-support:0.11.01' // Assets/GeneratedLocalRepo/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
// Android Resolver Dependencies End
    implementation(name: 'com.google.android.gms.play-services-games-v2-20.1.2', ext:'aar')
    implementation(name: 'UnityAds', ext:'aar')
    implementation(name: 'common', ext:'aar')
    implementation(name: 'com.google.android.gms.play-services-drive-17.0.0', ext:'aar')
    implementation(name: 'com.google.android.gms.play-services-cloud-messaging-17.3.0', ext:'aar')
    implementation(name: 'firebase-messaging-cpp', ext:'aar')
    implementation(name: 'com.google.android.gms.play-services-tasks-18.2.0', ext:'aar')
    implementation(name: 'com.google.android.gms.play-services-basement-18.4.0', ext:'aar')
    implementation(name: 'com.google.android.gms.play-services-stats-17.1.0', ext:'aar')
    implementation(name: 'com.google.android.gms.play-services-base-18.5.0', ext:'aar')
    implementation project('FirebaseApp.androidlib')
    implementation project('GooglePlayGamesManifest.androidlib')

	implementation 'com.google.android.play:asset-delivery:2.1.0'
}
1 Like

Appreciate this; I have conveyed the information to the team who is trying to reproduce the issue as we speak.

1 Like

I too am having this exact problem. Compiles fine but crashes immediately with the same

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions;

What’s crazy is, I’m not an android dev, I kept changing random stuff in my project, relative to compile settings/ minify/ etc., gradle files, custom not custom, updating libraries, adding dependencies manually to the mainTemplate.gradle.

I got it to build just once without crashing, but then rebuilding it with a changed minSdkTarget caused the NoClassDefFoundError error and going back tot he old minSdkTarget didn’t fix it.

I am using the UPM version of EDM4U v1.2.182.

I have yet to try The702Guy fix, but I am hoping it will fix it.

As it stands prefix this is my generated dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
    implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' // Assets/LevelPlay/Editor/IronSourceSDKDependencies.xml:17
    implementation 'com.google.android.gms:play-services-base:18.5.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:17
    implementation 'com.google.android.gms:play-services-basement:18.1.0' // Assets/LevelPlay/Editor/IronSourceSDKDependencies.xml:25
    implementation 'com.google.firebase:firebase-analytics:22.0.2' // Assets/Firebase/Editor/StorageDependencies.xml:15
    implementation 'com.google.firebase:firebase-analytics-unity:12.2.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    implementation 'com.google.firebase:firebase-app-unity:12.2.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    implementation 'com.google.firebase:firebase-auth:23.0.0' // Assets/Firebase/Editor/AuthDependencies.xml:13
    implementation 'com.google.firebase:firebase-auth-unity:12.2.0' // Assets/Firebase/Editor/AuthDependencies.xml:20
    implementation 'com.google.firebase:firebase-common:21.0.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    implementation 'com.google.firebase:firebase-database:21.0.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:13
    implementation 'com.google.firebase:firebase-database-unity:12.2.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:22
    implementation 'com.google.firebase:firebase-firestore:25.0.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:13
    implementation 'com.google.firebase:firebase-firestore-unity:12.2.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:20
    implementation 'com.google.firebase:firebase-storage:21.0.0' // Assets/Firebase/Editor/StorageDependencies.xml:13
    implementation 'com.google.firebase:firebase-storage-unity:12.2.0' // Assets/Firebase/Editor/StorageDependencies.xml:20
    implementation 'com.ironsource.adapters:unityadsadapter:4.3.42' // Assets/LevelPlay/Editor/ISUnityAdsAdapterDependencies.xml:8
    implementation 'com.ironsource.sdk:mediationsdk:8.2.1' // Assets/LevelPlay/Editor/IronSourceSDKDependencies.xml:9
    implementation 'com.ironsource.unity:adqualitysdk:7.20.4' // Assets/IronSourceAdQuality/Editor/IronSourceAdQualityDependencies.xml:17
    // implementation 'com.ironsource:adqualitysdk:7.20.3' // Assets/LevelPlay/Editor/IronSourceAdQualityDependencies.xml:9
    implementation 'com.ironsource:adqualitysdk:7.20.4' // Assets/IronSourceAdQuality/Editor/IronSourceAdQualityDependencies.xml:9
    implementation 'com.unity3d.ads:unity-ads:4.12.2' // Assets/LevelPlay/Editor/ISUnityAdsAdapterDependencies.xml:15
// Android Resolver Dependencies End
**DEPS**}

I got it working by manually downloading and adding the following libraries as OP suggested, from the maven website they linked, and put them in Assets/Plugins/Android:

	implementation project('FirebaseApp.androidlib')
	implementation(name: 'common', ext:'aar')
	implementation(name: 'play-services-games-v2-20.1.2', ext:'aar')
	implementation(name: 'play-services-tasks-18.2.0', ext:'aar')
	implementation(name: 'play-services-basement-18.4.0', ext:'aar')
	implementation(name: 'play-services-base-18.5.0', ext:'aar')

This is my final mainTemplate.gradle dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
	implementation project('FirebaseApp.androidlib')
	implementation(name: 'common', ext:'aar')
	implementation(name: 'play-services-games-v2-20.1.2', ext:'aar')
	implementation(name: 'play-services-tasks-18.2.0', ext:'aar')
	implementation(name: 'play-services-basement-18.4.0', ext:'aar')
	implementation(name: 'play-services-base-18.5.0', ext:'aar')
// Android Resolver Dependencies Start
    implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' // Assets/LevelPlay/Editor/IronSourceSDKDependencies.xml:17
    implementation 'com.google.android.gms:play-services-base:18.5.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:17
    implementation 'com.google.android.gms:play-services-basement:18.4.0' // Assets/LevelPlay/Editor/IronSourceSDKDependencies.xml:25
    implementation 'com.google.android.play:core-common:2.0.4' // Assets/GooglePlayPlugins/com.google.play.core/Editor/Dependencies.xml:3
    implementation 'com.google.firebase:firebase-analytics:22.0.2' // Assets/Firebase/Editor/StorageDependencies.xml:15
    implementation 'com.google.firebase:firebase-analytics-unity:12.2.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    implementation 'com.google.firebase:firebase-app-unity:12.2.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    implementation 'com.google.firebase:firebase-auth:23.0.0' // Assets/Firebase/Editor/AuthDependencies.xml:13
    implementation 'com.google.firebase:firebase-auth-unity:12.2.0' // Assets/Firebase/Editor/AuthDependencies.xml:20
    implementation 'com.google.firebase:firebase-common:21.0.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    implementation 'com.google.firebase:firebase-database:21.0.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:13
    implementation 'com.google.firebase:firebase-database-unity:12.2.0' // Assets/Firebase/Editor/DatabaseDependencies.xml:22
    implementation 'com.google.firebase:firebase-firestore:25.0.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:13
    implementation 'com.google.firebase:firebase-firestore-unity:12.2.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:20
    implementation 'com.google.firebase:firebase-storage:21.0.0' // Assets/Firebase/Editor/StorageDependencies.xml:13
    implementation 'com.google.firebase:firebase-storage-unity:12.2.0' // Assets/Firebase/Editor/StorageDependencies.xml:20
    implementation 'com.ironsource.adapters:unityadsadapter:4.3.42' // Assets/LevelPlay/Editor/ISUnityAdsAdapterDependencies.xml:8
    implementation 'com.ironsource.sdk:mediationsdk:8.2.1' // Assets/LevelPlay/Editor/IronSourceSDKDependencies.xml:9
    implementation 'com.ironsource:adqualitysdk:7.20.3' // Assets/LevelPlay/Editor/IronSourceAdQualityDependencies.xml:9
    implementation 'com.unity3d.ads:unity-ads:4.12.2' // Assets/LevelPlay/Editor/ISUnityAdsAdapterDependencies.xml:15
// Android Resolver Dependencies End
**DEPS**}

If you’re using Unity 2021 or newer and Firebase 10+, the way Gradle is integrated has changed. Gradle templates are now part of the Unity build pipeline and need to be handled properly.

Follow these steps to ensure a clean and working setup:


Step 1: Clean Existing Setup

  • Delete any Gradle files in Assets/Plugins/Android/ unless they contain changes you need to preserve.
  • Remove all existing Firebase folders and files from your project (e.g., anything under Assets/Firebase/ or similar).

Step 2: Re-import Firebase SDK

  • Re-import your Firebase Unity SDK packages (e.g., Firebase App, Auth, Analytics, etc.).
  • After importing, go to Assets > External Dependency Manager > Android Resolver > Force Resolve.
  • This will generate the necessary Gradle files:
    • mainTemplate.gradle
    • gradleTemplate.properties
    • settingsTemplate.gradle

Step 3: Configure Your Gradle Template

  • Open mainTemplate.gradle.
  • Make sure the namespace value matches your app’s Bundle Identifier (found in Project Settings > Player > Android > Other Settings > Identification).

Step 4: Handle Build Warnings

  • When Unity prompts you with a warning about deprecated packaging options, select “No”. Let Unity handle it as-is.

Step 5: Clean Build Environment

  • Before building, delete the Library/Bee folder.
  • This is especially important if you’ve previously done a build. It clears any cached build data.

Step 6: Fix Firebase Initialization Code

If your code looks like this:

csharp

CopyEdit

Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { ... });

Replace it with:

csharp

CopyEdit

Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => { ... });

Avoid using .ContinueWith directly—it can run on the wrong thread and cause issues.


After completing these steps, do a fresh build. Your Firebase setup should now initialize and run without issues on Android.