Android Question [Solved] java.lang.NullPointerException: Firebase Database component is not present.

musaso

Active Member
Licensed User
Longtime User
Sorry for my bad English.
I use FirebaseRealtimeDatabase v2.82 DonManfred.
Since the update B4A v9.30 Beta #3 I have this error:
B4X:
java.lang.NullPointerException: Firebase Database component is not present.
    at com.google.android.gms.common.internal.Preconditions.checkNotNull(Unknown Source)
    at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:120)
    at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:60)
    at de.donmanfred.FirebaseDatabaseWrapper.Initialize(FirebaseDatabaseWrapper.java:24)
    at com.modes.conversor.main._accederafirebase(main.java:440)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
    at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:1030)
    at com.modes.conversor.starter$ResumableSub_TimerService_Tick.resume(starter.java:250)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1705)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5219)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)

Any help will be well received thanks.
 

DonManfred

Expert
Licensed User
Longtime User
Google has changed the SDK.

You need to extend the ComponentDiscoveryService by adding DatabaseRegistrar.

Add this to the end of your manifest (manifesteditor)

B4X:
AddApplicationText(
<service android:name="com.google.firebase.components.ComponentDiscoveryService" >
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
    android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
    android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
    android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
    android:value="com.google.firebase.components.ComponentRegistrar"/>
</service>
)
 
Last edited:
Upvote 0

Multiverse app

Active Member
Licensed User
Longtime User
Google has changed the SDK.

You need to extend the ComponentDiscoveryService by adding DatabaseRegistrar.

Add this to the end of your manifest (manifesteditor)

B4X:
AddApplicationText(
<service android:name="com.google.firebase.components.ComponentDiscoveryService" >
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
    android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
    android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
    android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
    android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
    android:value="com.google.firebase.components.ComponentRegistrar"/>
</service>
)

Hi Don, I added this, still the issue persists for me at Realtimedb.Initialize("Realtimedb"):

B4X:
Error occurred on line: 30 (Starter)
java.lang.NullPointerException: Firebase Database component is not present.
    at com.google.android.gms.common.internal.Preconditions.checkNotNull(Unknown Source)
    at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:120)
    at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:60)
    at de.donmanfred.FirebaseDatabaseWrapper.Initialize(FirebaseDatabaseWrapper.java:25)
    at com.multiverse.doctorify.starter._service_create(starter.java:309)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at com.multiverse.doctorify.starter.onCreate(starter.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761)
    at android.app.ActivityThread.access$1800(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5265)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Hi Don, I added this, still the issue persists for me at Realtimedb.Initialize("Realtimedb"):
You should never post a new question in an existing thread. Always start your own thread.

1. Create a new thread for your issue!
2. Make sure to post all relevant infos
 
Upvote 0
Top