Android Question B4A V 12.2 Default FirebaseApp is not initialized

rachman

Member
Licensed User
Longtime User
Dear All,

I want to update my previous application in Google play store, which is need upgrade API to 31. And from the forum, I get information to update B4a and all libraries, I have done all the step, but seems my application didn't running well

Here's the error

error:
Logger connected to:  HMD Global Nokia G20
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 35 (Main)
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process whizmate.app. Make sure to call FirebaseApp.initializeApp(Context) first.
    at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:186)
    at com.google.firebase.auth.FirebaseAuth.getInstance(com.google.firebase:firebase-auth@@22.0.0:1)
    at anywheresoftware.b4a.objects.FirebaseAuthWrapper.Initialize(FirebaseAuthWrapper.java:68)
    at whizmate.app.main._activity_create(main.java:452)
    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 whizmate.app.main.afterFirstLayout(main.java:105)
    at whizmate.app.main.access$000(main.java:17)
    at whizmate.app.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7700)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)
** Activity (main) Resume **

And this is my manifest file

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: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="31"/>
<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.LightTheme)
'End of default text.
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
AddPermission(android.permission.NFC)
AddPermission(android.permission.CAMERA) 
AddPermission(android.permission.CAPTURE_AUDIO_OUTPUT) 
AddPermission(android.permission.CAPTURE_SECURE_VIDEO_OUTPUT) 
AddPermission(android.permission.CAPTURE_VIDEO_OUTPUT)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)

CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)

this is my application b4a

about.JPG


anyone can help me, I am stuck in these :(
 

josejad

Expert
Licensed User
Longtime User
From the 12.0+, you must update the SDK too. Have you done it?

You must download an updated Android SDK + additional resources, in order to use the new version.

Follow the installation guide and try again.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Don't you miss these lines from the manifest?

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

From this

Google Play Services Base - Always required when using Google Play Services or Firebase:

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
Firebase - Always required when using Firebase

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
 
Upvote 0

rachman

Member
Licensed User
Longtime User
Yes, I have update SDK too, to this link . These is for my configuration paths

about.JPG


and also update my manifest

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: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="31"/>
<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.LightTheme)
'End of default text.
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
AddPermission(android.permission.NFC)
AddPermission(android.permission.CAMERA) 
AddPermission(android.permission.CAPTURE_AUDIO_OUTPUT) 
AddPermission(android.permission.CAPTURE_SECURE_VIDEO_OUTPUT) 
AddPermission(android.permission.CAPTURE_VIDEO_OUTPUT)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)

but my application has stop and close without show any error.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
No error on the logs after compiling?
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
By the way, you should put your additionals libraries in other folder than the default one. You're mixing internal libraries with additional ones

1684489184445.png




EDIT: Hummmm... now B4A is x64, and you're reading your additional libraries mixed with the internal ones from x86 folder... maybe you're getting some kind of problems from this point... not sure
 
Last edited:
Upvote 0

rachman

Member
Licensed User
Longtime User
I have update the config but the result still same

1111.JPG


the application still not running, any one can give me sample ? I really appreciate


thank you
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Maybe you can get some clues searching for the same error:


or maybe you can show your code or even better, upload a small project showing the error.
 
Upvote 0

rachman

Member
Licensed User
Longtime User
Ok this is sample code, from tutorial

code:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
    
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private lblName As Label
    Private btnSignInFacebook As Button
    Private btnSignInGoogle As Button
    Private btnSignOut As Button
    Public auth As FirebaseAuth
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    auth.Initialize("auth")
    Activity.LoadLayout("1")
End Sub

Sub Auth_SignedIn (User As FirebaseUser)
    Log("SignedIn: " & User.DisplayName)
    'CallSub(Main, "SetState")
    SetState
    Log(User.Uid)
    Log(User.Email)
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btnSignInGoogle_Click
    auth.SignInWithGoogle
End Sub

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

Sub SetState
    If auth.CurrentUser.IsInitialized Then
        Dim cu As FirebaseUser = auth.CurrentUser
        lblName.Text = "Hello: " & cu.DisplayName
    End If
    For Each btn As Button In Array (btnSignInFacebook, btnSignInGoogle)
        btn.Enabled = Not(auth.CurrentUser.IsInitialized)
    Next
    btnSignOut.Enabled = auth.CurrentUser.IsInitialized
End Sub
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
By the way, have you follow this advice from Erel?

Edit: FirebaseMessaging should be a Receiver. Not a service.
 
Last edited:
Upvote 0

josejad

Expert
Licensed User
Longtime User
Upvote 0

rachman

Member
Licensed User
Longtime User
Post your Manifestcode please. Just the code alone is not enough.
Here is my manifest

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: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="31"/>
<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.LightTheme)
'End of default text.
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
AddPermission(android.permission.NFC)
AddPermission(android.permission.CAMERA)
AddPermission(android.permission.CAPTURE_AUDIO_OUTPUT)
AddPermission(android.permission.CAPTURE_SECURE_VIDEO_OUTPUT)
AddPermission(android.permission.CAPTURE_VIDEO_OUTPUT)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
 
Upvote 0

rachman

Member
Licensed User
Longtime User
Here is the google-services.json in my application

json-google:
{
  "project_info": {
    "project_number": "352663127648",
    "project_id": "test-dbc27",
    "storage_bucket": "test-dbc27.xxxxx.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:352663127648:android:asasad4212412421",
        "android_client_info": {
          "package_name": "coba.whiz"
        }
      },
      "oauth_client": [
        {
          "client_id": "352663127648-asdasda124214214214.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "coba.whiz",
            "certificate_hash": "ec6da75efacc94sadds2113494884ca5e66889b0836f8cead"
          }
        },
        {
          "client_id": "352663127648-1u1ujkldjsaljdlasdas.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "sadsad24215-oh_TSips3i-Bc"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": [
            {
              "client_id": "352663127648-asdsad3245123421.apps.googleusercontent.com",
              "client_type": 3
            }
          ]
        }
      }
    }
  ],
  "configuration_version": "1"
}

Any one can give suggestion? I really appreciate
 
Last edited:
Upvote 0

josejad

Expert
Licensed User
Longtime User
Works the original sample project for you with your json and your project name?
 
Upvote 0
Top