Android Question App Crashes on Startup When Adding Firebase Manifest Snippets in B4A

udaryl

Member
Hi everyone,

I'm trying to integrate Firebase Cloud Messaging (FCM) into my B4A app, but I'm encountering a problem where the app crashes immediately on startup.

Here are the details:

- I’ve downloaded the correct `google-services.json` from Firebase and placed it in the root directory of my B4A project.
- The package name in Firebase exactly matches my project.
- These are the Firebase-related lines I’m trying to use in the manifest editor:

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

- The app **only works when I include just the first line**:

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

As soon as I add the second or third line, the app crashes instantly on startup — it doesn't even reach the main activity.

- These are the libraries I have enabled in my project:
- ByteConverter 1.10
- Core 13.01
- FirebaseAnalytics 3.01
- FirebaseNotifications 3.11
- OkHttp 1.50
- OkHttpUtils2 3.04
- Phone 2.60
- RuntimePermissions 1.20
- SharedPreferences 1.00
- StringUtils 1.12
- XUI 2.32

I’ve followed the Firebase integration tutorial as closely as possible. Is there something I’m missing? Maybe a dependency or version issue?

Any help or suggestions would be greatly appreciated.
Thanks!
 

AmirPYTHON

Member
Response to the app crashing issue when integrating FCM into B4A:

Based on your description, the main issue is probably related to the dependency settings or versions of the Firebase libraries. Follow these steps to fix the problem:

1. **Check full logs (Unfiltered Logs)**:
- Enable **Unfiltered Logs** via B4A > Logs > menu
- Errors related to `ClassNotFoundException` or `MethodNotFoundException` usually indicate dependency issues

2. **Check library versions**:
- FirebaseAnalytics 3.01 and FirebaseNotifications 3.11 libraries may be incompatible

3. **Order of adding resources in the manifest**:
This:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)

CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
- Try this new order

4. **Check third-party dependencies**:
- Make sure you have updated the Android SDK to the latest version
- In the Android SDK Manager, these packages should be installed are:
- Google Play Services
- Google Repository
- Android Support Repository

5. **Advanced Settings**:
- In the `google-services.json` file, make sure:
- ``package_name`` exactly matches the name of the project package
- Firebase Analytics and Cloud Messaging services are enabled in the Firebase console

6. **Development Environment Update**:
- Install the latest version of B4A (at least version 12.0)
- If necessary, use the B4A Bridge environment instead of USB Debugging

After applying these changes, recompile the project and check the logs. If the problem persists, submit the specific error that appears in the log for further analysis.
 
Upvote 0

udaryl

Member
Check the unfiltered logs. There must be an error message there.
The unfiltered logs contain a `java.lang.NoClassDefFoundError` for `Lcom/google/android/datatransport/TransportFactory;`, but this class appears to be installed with the SDK.
 
Upvote 0

udaryl

Member
05-25 13:18:42.911 9419 9419 W ComponentDiscovery: Class com.google.firebase.auth.FirebaseAuthRegistrar is not an found.
05-25 13:18:42.912 9419 9419 W ComponentDiscovery: Class com.google.firebase.abt.component.AbtRegistrar is not an found.
05-25 13:18:42.913 9419 9419 W ComponentDiscovery: Class com.google.firebase.iid.Registrar is not an found.
05-25 13:18:42.913 9419 9419 W ComponentDiscovery: Class com.google.firebase.firestore.FirestoreRegistrar is not an found.
05-25 13:18:42.913 9419 9419 D AndroidRuntime: Shutting down VM
05-25 13:18:42.914 9419 9419 E AndroidRuntime: FATAL EXCEPTION: main
05-25 13:18:42.914 9419 9419 E AndroidRuntime: Process: com.test.app, PID: 9419
05-25 13:18:42.914 9419 9419 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/datatransport/TransportFactory;
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.messaging.FirebaseMessagingRegistrar.getComponents(FirebaseMessagingRegistrar.java:48)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.tracing.ComponentMonitor.processRegistrar(ComponentMonitor.java:28)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.components.ComponentRuntime.discoverComponents(ComponentRuntime.java:118)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:100)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:46)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.components.ComponentRuntime$Builder.build(ComponentRuntime.java:407)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:439)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:296)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:264)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:249)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2404)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2374)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:7464)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6981)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6752)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.app.ActivityThread.access$1500(ActivityThread.java:256)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7875)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1005)
05-25 13:18:42.914 9419 9419 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: com.google.android.datatransport.TransportFactory
05-25 13:18:42.914 9419 9419 E AndroidRuntime: ... 26 more
 
Upvote 0

udaryl

Member
Delete your Android SDK and download the two components: https://www.b4x.com/b4a.html
Don't update or install anything else.
Thanks very much, it's fixed.

But I have a new problem.
I'm not using B4XPages.

When I try to do this:

StartReceiver(FirebaseMessaging)
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")

I get this on log:
sending message to waiting queue of uninitialized activity (subscribetotopics)
 
Upvote 0
Top