Android Question How to fix error "Default FirebaseApp is not initialized": Firebase RemoteConfig + manifest snippet

asales

Expert
Licensed User
Longtime User
I'm using this lib Firebase RemoteConfig and works fine, but in device with Android 4.2, I get this error:
B4X:
main$ResumableSub_Activity_Createresume (java line: 1051)
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process br.com.myprofiles. Make sure to call FirebaseApp.initializeApp(Context) first.
    at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@19.3.0:184)
    at com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(com.google.firebase:firebase-config@@19.1.4:79)
    at de.donmanfred.FirebaseRemoteConfigwrapper.Initialize(FirebaseRemoteConfigwrapper.java:36)
    at br.com.myprofiles.main$ResumableSub_Activity_Create.resume(main.java:1051)
    at br.com.myprofiles.main._activity_create(main.java:1017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at br.com.myprofiles.main.afterFirstLayout(main.java:104)
    at br.com.myprofiles.main.access$000(main.java:17)
    at br.com.myprofiles.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5279)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at dalvik.system.NativeStart.main(Native Method)
I checked the problem and the cause is in manifest snippet.
The instructions of the lib FirebaseConfig says:
Replace in the Manifest editor the line
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
with
CreateResourceFromFile(Macro, FirebaseRemoteConfig.Firebase)

If I replace the snippet, the error will be generated.
I can check the SDK version in the code and initialize the lib only if SDK > 18 (4.4+) but it possible check the SDK version in the manifest and select the new snippet only to SDK 19+?

Thanks in advance for any tip.
 

DonManfred

Expert
Licensed User
Longtime User
Does it work if you set minsdk to 19 in the manifest?
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Does it work if you set minsdk to 19 in the manifest?
Nope.
I checked now in a device with Android 4.4 and I got the same error:

B4X:
main$ResumableSub_Activity_Createresume (java line: 1051)
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process br.com.myprofiles. Make sure to call FirebaseApp.initializeApp(Context) first.
    at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@19.3.0:184)
    at com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(com.google.firebase:firebase-config@@19.1.0:77)
    at de.donmanfred.FirebaseRemoteConfigwrapper.Initialize(FirebaseRemoteConfigwrapper.java:36)
    at br.com.myprofiles.main$ResumableSub_Activity_Create.resume(main.java:1051)
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I thought the problem was with the old devices (Android < 4.4) and I change the minimum SDK to 22 (Android 5.1).
Saddly I get this same error in Android 8.1:

B4X:
Fatal Exception: java.lang.IllegalStateException
Default FirebaseApp is not initialized in this process br.com.myprofiles. Make sure to call FirebaseApp.initializeApp(Context) first.
com.google.firebase.FirebaseApp.getInstance (com.google.firebase:firebase-common@@19.3.0:184)
com.google.firebase.messaging.FirebaseMessaging.getInstance (com.google.firebase:firebase-messaging@@20.1.0:1)
anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.Initialize (FirebaseNotificationsService.java:97)
br.com.myprofiles.firebasemessaging._service_create (firebasemessaging.java:174)

This lib is essential to make A/B Tests in Firebase, but I don't know how to fix this problem.
 
Upvote 0
Top