Android Question Firebase Auth error

gigi0ne

Member
Licensed User
Longtime User
Hello everybody

I have a little problem,

when I try to use the firebase authentication library
when the program arrives at auth initialization it gives me this error message and exits

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

what can it be
Thank you

AUTH Firebase:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        auth.Initialize("auth")
    End If
    Activity.LoadLayout("1")
    If auth.CurrentUser.IsInitialized Then Auth_SignedIn(auth.CurrentUser)
End Sub

Sub btnSignIn_Click
    auth.SignInWithGoogle
End Sub

Sub btnSignOut_Click
    auth.SignOutFromGoogle
    lblName.Text = "Goodbye!"
End Sub

Sub Auth_SignedIn (User As FirebaseUser)
    Log("SignedIn: " & User.DisplayName)
    lblName.Text = "Hello: " & User.DisplayName
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
you are using which B4A Version?
What is you manifesttext?
can you post the generated manifest?
 
Upvote 0

gigi0ne

Member
Licensed User
Longtime User
Thank's Manfred

B4A 11.5

Manifest:
'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: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
'************ Google Play Services Base ************
AddApplicationText(
    <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:exported="false"/>
     <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
)
'************ Google Play Services Base (end) ************

'************ Firebase Base ************
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />)
AddApplicationText(
<receiver
          android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
          android:enabled="true">
        <intent-filter>
          <action android:name="com.google.android.gms.measurement.UPLOAD"/>
        </intent-filter>
      </receiver>

      <service
          android:name="com.google.android.gms.measurement.AppMeasurementService"
          android:enabled="true"
          android:exported="false"/>   
    <provider
            android:authorities="${applicationId}.firebaseinitprovider"
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:exported="false"
            android:initOrder="100" />
      <receiver
          android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
          android:enabled="true">
        <intent-filter>
          <action android:name="com.google.android.gms.measurement.UPLOAD"/>
        </intent-filter>
      </receiver>

      <service
          android:name="com.google.android.gms.measurement.AppMeasurementService"
          android:enabled="true"
          android:exported="false"/>
    <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
       <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
            android:exported="false" />

    
        <service
            android:name="com.google.firebase.iid.FirebaseInstanceIdService"
            android:exported="true">
            <intent-filter android:priority="-500">
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>
)
'************ Firebase Base (end) ************
'************ Firebase Auth ************
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
AddApplicationText(
   <activity android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:excludeFromRecents="true"
                  android:exported="false" />

        <service
            android:name="com.google.android.gms.auth.api.signin.RevocationBoundService"
            android:exported="true"
            android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />
)
'************ Firebase Auth (end) ************
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
you manifesttext is wrong. This was needed years ago like this!

Follow the Firebase-instructions carefully

 
Upvote 1

gigi0ne

Member
Licensed User
Longtime User
you manifesttext is wrong. This was needed years ago like this!

Follow the Firebase-instructions carefully

perfect thanks
 
Upvote 0
Top