Android Question SDK update + Firebase UI Auth

yiankos1

Well-Known Member
Licensed User
Longtime User
Hello my friends,
I use @DonManfred library to authenticate users. Everything was working perfect till today, when i updated recommended sdk updates. Now it throws this error:
B4X:
User exists=1
Error occurred on line: 431 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken()' on a null object reference
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.getToken(FirebaseNotificationsService.java:122)
    at com.dreamon.seeida.main._userexists_result(main.java:3755)
    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:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    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:5942)
    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:1388)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)

Code that throws this error:
B4X:
    Private fm As FirebaseMessaging
    fm.Initialize("fm")

    Starter.token=fm.Token

If i put a breakpoint at this line of code "Starter.token=fm.Token" it says this: "Error: Cannot run method from watch expression." But even if i put this code to Activity_Start throws again same error. I think that by sdk update something changed and this lib corrupted.
Thank you for your time.
 

yiankos1

Well-Known Member
Licensed User
Longtime User
Did you checked my answer in #17? Does it work for you?
Just installed artifacts mentioned above. All checked one by one... Still i got same error... Do you think is something else? or i did something wrong?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
or i did something wrong?
i´m not sure what the problem is.
All i can say is that i added Firebasemessaging to my FirebaseUIAuth-Example App and i was able to compile it successfully.
 
Upvote 0

alimanam3386

Active Member
Licensed User
Longtime User
I can compile but when my app start it crash , please have a look to log error :

error_firebase_notification.jpg


B4X:
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
Error occurred on line: 19 (FirebaseMessaging)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken()' on a null object reference
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.getToken(FirebaseNotificationsService.java:122)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at uk.qbeesoft.wannachat.firebasemessaging.handleStart(firebasemessaging.java:100)
    at uk.qbeesoft.wannachat.firebasemessaging.access$000(firebasemessaging.java:8)
    at uk.qbeesoft.wannachat.firebasemessaging$1.run(firebasemessaging.java:71)
    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:221)
    at uk.qbeesoft.wannachat.firebasemessaging.onStartCommand(firebasemessaging.java:69)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4062)
    at android.app.ActivityThread.access$2400(ActivityThread.java:221)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1897)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7225)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
It happens here too when i run the app.
Looks for me that the FirebaseMessaging Library needs an update or so.
So what do you advise us to do? Should we make a new post about firebase messaging in order @Erel update it? One more question, what about the other case for simultaneously event raises? Is it fixable you think?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You need to change the whole wrapper in order to fix this?
not really. Must change it a bit and move codelogic to b4a part. But it is not much
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    fbauth.Initialize("FBAuth")
    fbal = fbauth.CreateListener
End Sub
Sub Activity_Resume
    fbauth.AddAuthStateListener(fbal)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    fbauth.RemoveAuthStateListener(fbal)
End Sub
Need to test it this weekend
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
not really. Must change it a bit and move codelogic to b4a part. But it is not much
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    fbauth.Initialize("FBAuth")
    fbal = fbauth.CreateListener
End Sub
Sub Activity_Resume
    fbauth.AddAuthStateListener(fbal)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    fbauth.RemoveAuthStateListener(fbal)
End Sub
Need to test it this weekend
Thank you very much for your time. I will subscribe at Firebase UI Auth post in order to update my library when you upload it. Wish you a great night.
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
Infoupdate:
- It crashes when using Firebasenotification TOO.
- It does NOT crash without Firebasenotifications.

So it seems to me that the Firebasemessaging library needs an update and we just need to wait for an Update.
Indeed crashes me too. If you find time at Saturday or Sunday can you fix firebase ui event listener in order not to raises many times simultaneously?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If you find time at Saturday or Sunday can you fix firebase ui event listener in order not to raises many times simultaneously?
I did tried...

I updated all Artifacts, i updated the Firebase UI - Code from Github to the newest release (last updated about a month ago).
I realized that google has changed the way to add a Auth-Provider.
I needed to rewrite the wrapper to match the new Google-Rules.
After i came into different errors it is all done now.
But now, when i call the FirebaseUI to show the available Providerslist to select one from it crashes because of
Logger verbunden mit: 988ad036525346515630
--------- beginning of crash
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
FBAuth_SignedIn
You are logged offf
** Activity (main) Pause, UserClosed = false **
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/arch/lifecycle/ViewModelProviders;
at com.firebase.ui.auth.KickoffActivity.onCreate(KickoffActivity.java:32)
at android.app.Activity.performCreate(Activity.java:7174)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6940)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.ViewModelProviders" on path: DexPathList[[zip file "/data/app/de.donmanfred.fbui-QjQ2LbCEDiSYCIiKUToRZA==/base.apk"],nativeLibraryDirectories=[/data/app/de.donmanfred.fbui-QjQ2LbCEDiSYCIiKUToRZA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 13 more

android/arch/lifecycle/ViewModelProviders is part of android.arch.lifecycle.viewmodel

I tried to get rid of them using
B4X:
#AdditionalJar: android.arch.lifecycle:viewmodel
but the error is the same

I copied the aar from the B4A SDK Managers b4a_remote Folder...
I tried to use
B4X:
#AdditionalJar: viewmodel-1.1.1.aar
But then i get a error when compiling.

B4A Version: 8.00
Parse den Code. (0.00s)
Kompiliere den Code. (0.20s)
Kompiliere Layoutcode. (0.00s)
Organisiere Libraries. (3.18s)
Generiere R Datei. (2.22s)
Kompiliere generierten Java Code. (2.03s)
Byte-Code konvertieren - optimiert dex. Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/AndroidViewModel;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/ViewModel;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/ViewModelProvider;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/ViewModelProvider$AndroidViewModelFactory;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/ViewModelProvider$Factory;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/ViewModelProvider$NewInstanceFactory;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/ViewModelStore;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/arch/lifecycle/ViewModelStoreOwner;
8 errors; aborting

No matter what i try it does not work...
If i remember correctly then i read something in the past (maybe from Erel; can´t remember) that these Lifecycle components are added at compilitime when using Android Studio.

I guess they are included in the AARs which i created with AS.
#AdditionalJar: firebase-ui-auth.aar ' Probably this one
#AdditionalJar: firebase-ui-common.aar
#AdditionalJar: firebase-ui-database.aar
#AdditionalJar: firebase-ui-firestore.aar
#AdditionalJar: firebase-ui-storage.aar

But as of now i did not find a solution to get the new UI-Auth running. I dont know why the classes are not recognized to be available. :mad:
 
Upvote 0
Top