Android Question [Solved] Error in FirebaseMessaging Service (FirebaseStorage is the problem?)

asales

Expert
Licensed User
Longtime User
I've update the Android SDK and the internal libs and now I get the same error from this post:
https://www.b4x.com/android/forum/threads/solved-error-in-firebasemessaging-service.112202/

I don't use the FirebaseConfigRemote in this app, but AdMob, Analytics, Notifications and Storage.

If I change to the old SDK or remove the FirebaseStorage lib, the errors don't happen.

Do I need an update the FirebaseStorage lib?

This is the error:
B4X:
firebasemessaging_subscribetotopics (java line: 265)
java.lang.RuntimeException: Object should first be initialized (FirebaseMessaging).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.SubscribeToTopic(FirebaseNotificationsService.java:130)
    at br.com.myprofiles.firebasemessaging._subscribetotopics(firebasemessaging.java:265)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1179)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't use the FirebaseConfigRemote in this app, but AdMob, Analytics, Notifications and Storage.
The problem discussed here: https://www.b4x.com/android/forum/threads/solved-error-in-firebasemessaging-service.112202/#content is not really related to FirebaseConfigRemote. It is related to a manifest editor macro that overwrote the new declaration required for FirebaseMessaging.

There is not related to FirebaseStorage. I'm unable to reproduce this issue.

Update the recommended items in B4A Sdk Manager and use the latest version of FirebaseAnalytics. If it doesn't work then post your manifest editor code.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
The problem remains.

He my manifest:
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: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)   
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")
'End of default text.

SetApplicationAttribute(android:allowBackup, "false")

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <external-files-path name="name" path="" />
)

'************ Google Play Services Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
'************ Google Play Services Base (end) ************
'************ Firebase Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
'************ Firebase Base (end) ************
'************ Firebase Ads ************
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
'************ Firebase Ads (end) ************
'************ Firebase Analytics ************
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
'************ Firebase Analytics (end) ************
''************ Firebase Notifications / Push messages ************
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
'************ Firebase Notifications / Push messages (end) ************

CreateResourceFromFile(Macro, Core.NetworkClearText)

'************ Crashlytics ************
AddApplicationText(
 <provider
            android:name="com.crashlytics.android.CrashlyticsInitProvider"
            android:authorities="$PACKAGE$.crashlyticsinitprovider"
            android:exported="false"
            android:initOrder="100" />
           )
          
CreateResource(values, com_crashlytics_build_id.xml,
<resources xmlns:tools="http://schemas.android.com/tools">
<string tools:ignore="UnusedResources,,TypographyDashes" name="com.crashlytics.android.build_id"
   translatable="false">00000</string>
</resources>)
'************ Crashlytics (end) ************

'************ Firebase Storage ************
AddApplicationText(
 <service android:name="com.google.firebase.components.ComponentDiscoveryService" >
    <meta-data
          android:name="com.google.firebase.components:com.google.firebase.storage.StorageRegistrar"
          android:value="com.google.firebase.components.ComponentRegistrar" />
    <meta-data
          android:name="com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar"
          android:value="com.google.firebase.components.ComponentRegistrar"/>

    <meta-data
          android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
          android:value="com.google.firebase.components.ComponentRegistrar"/>
       <meta-data
          android:name="com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar"
          android:value="com.google.firebase.components.ComponentRegistrar" />
 </service>
)

AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
)

'This is a sample AdMob app id. You need to change it to your id.
AddReplacement($ADMOB_APP_ID$, ca-app-pub-)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
'************ Firebase Storage ************
AddApplicationText(
<
service android:name="com.google.firebase.components.ComponentDiscoveryService" >
<meta-data
android:name=
"com.google.firebase.components:com.google.firebase.storage.StorageRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name=
"com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar"/>

<meta-data
android:name=
"com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar"/>
<meta-data
android:name=
"com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</
service>
)

try without this code. It should be there already with the firebaseanalytics Macro
 
Upvote 0
Top