Android Question FirebaseAuth NullPointerException

JLock

Member
Licensed User
Getting the following error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
FirebaseAuth initialized
main_activity_create (java line: 443)
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.firebase.auth.FirebaseAuth.addAuthStateListener(com.google.firebase.auth.FirebaseAuth$AuthStateListener)' on a null object reference
at anywheresoftware.b4a.objects.FirebaseAuthWrapper.Initialize(FirebaseAuthWrapper.java:57)
at liteip.b4a.alite.main._activity_create(main.java:443)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at liteip.b4a.alite.main.afterFirstLayout(main.java:104)
at liteip.b4a.alite.main.access$000(main.java:17)
at liteip.b4a.alite.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6938)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Running B4A 8.30, have the FirebaseAuth from: https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.59340/#post-596101 - it is placed within the lib folder within my B4X directory. An additional copy has been placed in my external library folder but the error occurs with and without it there. I have ran SDK manager and installed all recommended things.

My manifest is as follows:
B4X:
'This code will be applied to the manifest file during compilation.

'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
'End of default text.

Lastly, my Activity_Create is as follows:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
    If FirstTime Then
        myDB.Initialize(File.DirInternal, "database.db", True)
        Auth.Initialize("auth")
    End If
  
    If Auth.CurrentUser.IsInitialized Then
        Auth_SignedIn(Auth.CurrentUser)
        MakeAllVisible
    End If
   
    ' TableView related things
    Table = ScrollView1.Panel
    Table.Color = TableColor
    LastProfile = 0
    LastDeviceRow = 0
  
    ' Initializing all required objects
    FoundDevices.Initialize
    CommandQueue.Initialize
    ForbiddenChars.Initialize
    ForbiddenChars.AddAll(Array As String("'", "&", ";", ",", "=", QUOTE))
    Admin.Initialize("Admin")
    Serial1.Initialize("Serial1")
  
    ' Creating the tables within the database.
    CreateTables
End Sub

Was wondering if anybody could point me in the right direction as to how to fix this/why it might be occuring. Thank you.
 
Last edited:

JLock

Member
Licensed User
If there is no recommended section, just installed and all, can I take that to mean all recommended items are updated?
 
Upvote 0

JLock

Member
Licensed User
It was version v1.04. I mistakenly dragged the FirebaseAuth jar and xml into B4J instead of basic4android the first time.

However, the error still persists upon doing it the second time around (correctly this time). It is v1.05 in the library manager.
 
Upvote 0

JLock

Member
Licensed User
I mistakenly assumed that FirebaseAnalytics was not necessary for FirebaseAuth due to my lack of knowledge in the field. Thank you for your help.
 
Upvote 0
Top