Following this tutorial again:
Created a new B4XPage project with B4A (Version 12.50).
Set my package name as in Google Firebase Console, which I use for my previous testing Firebase Push Notification app.
Go to Authentication, Sign-in method and add Google as a new provider.
Go to Project settings, download the google-services.json file and put inside the project.
Add the following into Manifest Editor.
Check the following libraries:
Add the following code in B4XMainPage.
Compile the project with bridge to a physical device (Android version 8.1.0).
Project compiled.
Click on "Sign in with Google" button.
Project crashed with error below.
FirebaseAuth - Authenticate your users
This library requires B4A v6+. It allows the users to sign in to your app with their Google account (more identity providers will be added in the future). Like all Firebase services it is quite simple to integrate this service in your app. 1. Follow this tutorial and make sure to add the...
www.b4x.com
Created a new B4XPage project with B4A (Version 12.50).
Set my package name as in Google Firebase Console, which I use for my previous testing Firebase Push Notification app.
Go to Authentication, Sign-in method and add Google as a new provider.
Go to Project settings, download the google-services.json file and put inside the project.
Add the following into Manifest Editor.
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
'CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
- FirebaseAnalytics (Version 3.00)
- FirebaseAuth (Version 3.00)
Add the following code in B4XMainPage.
B4XMainPage:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private lblName As Label
Private analytics As FirebaseAnalytics
Private auth As FirebaseAuth
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("1")
analytics.Initialize
auth.Initialize("auth")
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(User.Uid)
Log(User.Email)
Log("SignedIn: " & User.DisplayName)
lblName.Text = "Hello: " & User.DisplayName
End Sub
Sub Auth_SignError (Error As Exception)
Log(Error)
xui.MsgboxAsync(Error.Message, "Error")
End Sub
Sub Auth_TokenAvailable (User As FirebaseUser, Success As Boolean, TokenId As String)
Log(User)
Log(Success)
Log(TokenId)
End Sub
Project compiled.
Click on "Sign in with Google" button.
Project crashed with error below.
B4X:
Logger connected to: Xiaomi Redmi 5 Plus
--------- beginning of main
Copying updated assets files (2)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 27 (Main)
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:71)
at com.puterise.push.main._activity_create(main.java:394)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at com.puterise.push.main.afterFirstLayout(main.java:105)
at com.puterise.push.main.access$000(main.java:17)
at com.puterise.push.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzv@955c4ba
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
--------- beginning of crash
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at androidx.savedstate.SavedStateRegistryController$Companion.create(Unknown Source:2)
at androidx.savedstate.SavedStateRegistryController.create(Unknown Source:2)
at androidx.activity.ComponentActivity.<init>(ComponentActivity.java:146)
at androidx.fragment.app.FragmentActivity.<init>(FragmentActivity.java:108)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.<init>(com.google.android.gms:play-services-auth@@20.3.0:1)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1175)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.puterise.push-mBi1473bTlJStwjm7KHoRw==/base.apk"],nativeLibraryDirectories=[/data/app/com.puterise.push-mBi1473bTlJStwjm7KHoRw==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 17 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzv@3a22825
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at androidx.savedstate.SavedStateRegistryController$Companion.create(Unknown Source:2)
at androidx.savedstate.SavedStateRegistryController.create(Unknown Source:2)
at androidx.activity.ComponentActivity.<init>(ComponentActivity.java:146)
at androidx.fragment.app.FragmentActivity.<init>(FragmentActivity.java:108)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.<init>(com.google.android.gms:play-services-auth@@20.3.0:1)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1175)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.puterise.push-R08dStvsNavNkELJgb_uqw==/base.apk"],nativeLibraryDirectories=[/data/app/com.puterise.push-R08dStvsNavNkELJgb_uqw==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 17 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzv@d9f298f
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at androidx.savedstate.SavedStateRegistryController$Companion.create(Unknown Source:2)
at androidx.savedstate.SavedStateRegistryController.create(Unknown Source:2)
at androidx.activity.ComponentActivity.<init>(ComponentActivity.java:146)
at androidx.fragment.app.FragmentActivity.<init>(FragmentActivity.java:108)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.<init>(com.google.android.gms:play-services-auth@@20.3.0:1)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1175)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.puterise.push-R08dStvsNavNkELJgb_uqw==/base.apk"],nativeLibraryDirectories=[/data/app/com.puterise.push-R08dStvsNavNkELJgb_uqw==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 17 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzv@f08741c
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at androidx.savedstate.SavedStateRegistryController$Companion.create(Unknown Source:2)
at androidx.savedstate.SavedStateRegistryController.create(Unknown Source:2)
at androidx.activity.ComponentActivity.<init>(ComponentActivity.java:146)
at androidx.fragment.app.FragmentActivity.<init>(FragmentActivity.java:108)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.<init>(com.google.android.gms:play-services-auth@@20.3.0:1)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1175)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.puterise.push-spx5x_pIcftBiYCaEm_lIg==/base.apk"],nativeLibraryDirectories=[/data/app/com.puterise.push-spx5x_pIcftBiYCaEm_lIg==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 17 more
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzv@548bb87
** Activity (main) Resume **
SignInWithGoogle called
** Activity (main) Pause event (activity is not paused). **
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at androidx.savedstate.SavedStateRegistryController$Companion.create(Unknown Source:2)
at androidx.savedstate.SavedStateRegistryController.create(Unknown Source:2)
at androidx.activity.ComponentActivity.<init>(ComponentActivity.java:146)
at androidx.fragment.app.FragmentActivity.<init>(FragmentActivity.java:108)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.<init>(com.google.android.gms:play-services-auth@@20.3.0:1)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1175)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.puterise.push-ENJN0JSCe6uO8AyalyLsyA==/base.apk"],nativeLibraryDirectories=[/data/app/com.puterise.push-ENJN0JSCe6uO8AyalyLsyA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 17 more