I am building an app using unity2022.3.11.
The error
"The type initializer for ‘Firebase.FirebaseApp’ threw an exception"
is occurring in this code when launching on an Android device after build.
await FirebaseApp.CheckAndFixDependenciesAsync();
- What is the cause of this error?
- Is this due to build or is there something I should add from firebase unitypackage?
- If it cause of build, how do I configure gradle?
Resolve was done with the Android resolver in the External dependency manager.
Placed them in Assets/Plugins/Android.
baseProjectTemplate.gradle
gradleTemplate.properties
mainTemplate.gradle
settingTemplate.gradle
Filled in gradleTemplate.properties.
android.useAndroidX=true
android.enableJetifier=true
2
Answers
As I understand this, this functions should not be awaited as shown below
(This is an example of a FirebaseInit script I wrote)
I hope this will help you with resolving your error
As mentioned by TheCoderEll, typically you should not await
CheckAndFixDependenciesAsync
.The easiest/ most straightforward way is to use ContinueWithOnMainThread as shown in Firebase’s Level up With Firebase:
As for your build errors consult the following: Debugging the Game Build, Install and Run Process and EDM4U Usage Troubleshooting Guide