Updating Firebase causes RxBLE crash - android

Okay, so I'm having some very odd behaviour that doesn't make much sense in my app.
My app uses BLE and I have a static class which I initialize on app launch, this typically works with no issue.
Today I made a single change in my app which was to update this:
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
To this:
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
And after making this minor version update to firebase core, my app now immediately crashes on launch with the following error:
2020-02-13 09:44:57.530 20760-20760/my.package.name E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.package.name, PID: 20760
java.lang.NoSuchMethodError: No static method injectMembers(Ldagger/MembersInjector;Ljava/lang/Object;)Ljava/lang/Object; in class Ldagger/internal/MembersInjectors; or its super classes (declaration of 'dagger.internal.MembersInjectors' appears in /data/app/my.package.name-Nbmle9woVCiX-2v0teYwZw==/base.apk!classes3.dex)
at com.polidea.rxandroidble.RxBleAdapterStateObservable_Factory.get(RxBleAdapterStateObservable_Factory.java:28)
at com.polidea.rxandroidble.RxBleAdapterStateObservable_Factory.get(RxBleAdapterStateObservable_Factory.java:10)
at com.polidea.rxandroidble.RxBleClientImpl_Factory.get(RxBleClientImpl_Factory.java:104)
at com.polidea.rxandroidble.RxBleClientImpl_Factory.get(RxBleClientImpl_Factory.java:23)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.polidea.rxandroidble.DaggerClientComponent.rxBleClient(DaggerClientComponent.java:419)
at com.polidea.rxandroidble.RxBleClient.create(RxBleClient.java:54)
at my.package.name.Comm.RxBLEComm.<init>(RxBLEComm.java:109) // These are the only
at my.package.name.Comm.RxBLEComm.init(RxBLEComm.java:118) // lines in my code which
at my.package.name.RootApp.onCreate(RootApp.kt:63) // are totally unrealted to firebase
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1155)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5928)
at android.app.ActivityThread.access$1100(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6735)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2020-02-13 09:44:57.586 2989-3111/? E/NetworkController.MobileSignalController(2): showVoteIcon=false
Note: My app does not use dagger at all, though the RxBLE library might...
If I revert the firebase update the app builds and runs with no issue, so for now I'll just stick to using firebase-messaging:20.0.0 and firebase-core:17.2.1, but does anyone have any clue why this might be happening?
This is the only line of code required to make the crash happen:
RxBleClient.create(applicationContext)
Here is a test repo that you can reproduce the crash in:
https://github.com/Doophie/TestAppCrash
Note that there are 2 commits, in the first commit the app has updated firebase and crashes, the second commit it does not crash and uses the older firebase version.

So the issue was the version of the rxandroidble library was incompatible with the new firebase messaging.
When I updated from
implementation 'com.polidea.rxandroidble:rxandroidble:1.4.3'
to
implementation 'com.polidea.rxandroidble:rxandroidble:1.7.1'
the crash stopped.

Related

Runtime exception from room in a project that is not using room

I suddnly started getting this runtime exception at app launch without having room as my dependency at all.
07-20 19:48:37.703 18737-18771/mypackage.x E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
Process: mypackage, PID: 18737
java.lang.IllegalStateException: A migration from 3 to 2 was required but not found. Please provide the necessary Migration path via RoomDatabase.Builder.addMigration(Migration ...) or allow for destructive migrations via one of the RoomDatabase.Builder.fallbackToDestructiveMigration* methods.
at android.arch.persistence.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:97)
at android.arch.persistence.room.RoomOpenHelper.onDowngrade(RoomOpenHelper.java:109)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onDowngrade(FrameworkSQLiteOpenHelper.java:144)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:396)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54)
at android.arch.persistence.room.RoomDatabase.compileStatement(RoomDatabase.java:244)
at android.arch.persistence.room.SharedSQLiteStatement.createNewStatement(SharedSQLiteStatement.java:65)
at android.arch.persistence.room.SharedSQLiteStatement.getStmt(SharedSQLiteStatement.java:72)
at android.arch.persistence.room.SharedSQLiteStatement.acquire(SharedSQLiteStatement.java:87)
at androidx.work.impl.model.WorkSpecDao_Impl.resetScheduledState(WorkSpecDao_Impl.java:337)
at androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork(WorkManagerImpl.java:514)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
here are some of the dependencies that I do have from Android arch:
implementation "androidx.core:core-ktx:$ktx_version"
implementation "android.arch.paging:runtime:$paging_runtime"
implementation("android.arch.lifecycle:extensions:$android_arc_version") {
force = true
}
implementation "android.arch.navigation:navigation-fragment-ktx:$navigation_version"
// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui-ktx:$navigation_version"
implementation "android.arch.work:work-runtime-ktx:$work_version"
Any idea what might have caused this?
It turns out that android.arch.work:work had a dependency to the room library and I was using the version 1.0.0-alpha03 of work library. I thought of excluding the dependency but I noticed that an update is available for the work component and after trying that, it fixed the issue. So upgrade your work library to fix the issue (at this time the updated version is 1.0.0-alpha04)

Try send message to test if FCM works but the app crash

Trying to build a Firebase chat app and wanted to test if FCM works. Tried testing the notification function by sending a cloud messaging from the firebase console but the app crash in all the devices.
This is the error retrive from the logcat
06-30 16:11:07.783 26794-26794/com.example.ryzeng.firebasechat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ryzeng.firebasechat, PID: 26794
java.lang.NoSuchMethodError: No static method zzad()Lcom/google/firebase/iid/zzan; in class
Lcom/google/firebase/iid/zzan; or its super classes (declaration of
'com.google.firebase.iid.zzan' appears in
/data/app/com.example.ryzeng.firebasechat-2/split_lib_dependencies_apk.apk)
at com.google.firebase.messaging.FirebaseMessagingService.zzb(Unknown
Source)
at com.google.firebase.iid.zzb.onStartCommand(Unknown Source)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3366)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1612)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6236)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
In your project files , in file build.gradle ("Module: app")
change version of firebase messaging to last version like :
implementation 'com.google.firebase:firebase-messaging:20.1.4'
Work for me
When i Update firebase messaging dependency
from
implementation 'com.google.firebase:firebase-messaging:17.0.0'
to
implementation 'com.google.firebase:firebase-messaging:17.3.1'
It happens when you implement 2 or more Firebase with different versions.
So it's better to give same version to all firebase's implementation.
implementation 'com.google.firebase:firebase-ads:17.1.3'

Application crashing on some devices because "Default FirebaseApp is not initialized in this process"

I am using Firebase Crash Reporting and Firebase Remote Config. Version of both is 9.8.0.
On most devices setup works perfectly (I followed Set up crash reporting). But on small percentage of devices (it is actually crash with the highest occurrence) it crashes when I try to initialize Remote Config in Application onCreate method.
java.lang.RuntimeException: Unable to create application com.company.application.AppApplication: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6429)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7329)
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)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.a.d(Unknown Source)
at com.google.firebase.b.a.a(Unknown Source)
at com.company.application.d.a.a(SourceFile:21)
at com.company.application.AppApplication.onCreate(SourceFile:76)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6426)
... 8 more
Prior to version 10.0.0, Firebase Crash created an additional process in your app named background_crash. An instance of your AppApplication class is created and executed for each process in your app, including background_crash.
If you want to perform initialization of Firebase services in your application class, you need to add a guard to prevent the initialization from being performed in background_crash. On way to do that is:
if (!FirebaseApp.getApps(this).isEmpty()) {
// Not in crash process. Do your Remote Config init here.
}
Another solution is to upgrade to the latest version of Firebase, 10.0.1.
Assuming this answer is valid, I can't explain why the failure only occurs on some devices, unless the version of Google Play Services installed on the device is a factor, and the failing devices have an older version.
set classpath 'com.google.gms:google-services:4.0.1' in dependencies.
Implement the androidTestImplementation dependencies :
androidTestImplementation('com.android.support.test.espresso:espresso-core:.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})

Firebase Crash produces ANR during launch

Recently I got feedback and also I was able to reproduce it easily on my Nexus 5 with cleared app data.
Simply, when adding compile 'com.google.firebase:firebase-crash:9.4.0' only to project dependencies I get following Exception:
09-14 00:47:54.899 3129-3129/com.szyk.myheart E/FirebaseCrash: Failed to initialize crash reporting
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
at bol.<init>(:com.google.android.gms.DynamiteModulesC:3201)
at com.google.firebase.crash.internal.api.FirebaseCrashApiImpl.init(:com.google.android.gms.DynamiteModulesC:67)
at bnu.onTransact(:com.google.android.gms.DynamiteModulesC:60)
at android.os.Binder.transact(Binder.java:387)
at com.google.firebase.crash.internal.zzd$zza$zza.zza(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
The issue is more stranger, because once it will produce ANR and crash, then it works in next launches.
My dependencies:
compile 'com.google.firebase:firebase-core:9.4.0'
//not working compile 'com.google.firebase:firebase-crash:9.4.0'
compile 'com.google.firebase:firebase-invites:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-plus:9.4.0'
compile 'com.google.android.gms:play-services-drive:9.4.0'
The issue has been introduced with the Google Play Services 9.6.80 (currently in rollout) and affects all the apps using the Firebase Crash reporting (despite of the version bundled in your app).
Temporary solution: disable Firebase Crash by removing the following entry from the build.gradle:
compile 'com.google.firebase:firebase-crash:9.x.x'
Long term solution: wait that Google releases a fixed version of the GPS before enabling Firebase Crash again.
UPDATE 09/16:
Google is rolling out a fixed version of Google Play Services (9.6.83) which addresses the issue with Firebase Crash.
Disable the Firebase Analytics Crash Reporting, use the below code inside app.gradle file.Hope this will help you
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-crash'
}
9.6.83 still gives a different anr crash
Our app when pushed to Play Store Beta and when installed on devices crashes the first time on launch. Subsequently it works , but we cannot push to prod without understanding the issue.
Here is the ANR crash report
java.lang.RuntimeException: Unable to instantiate receiver com.google.android.gms.analytics.CampaignTrackingReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.analytics.CampaignTrackingReceiver"
Edit : We had to add compile 'com.google.android.gms:play-services-analytics:9.4.0' explicitly and the launch anr for first time got resolved. But I am not sure that was the fix as we dont use the library at all. Maybe Playstore fixed their bug to all apks?
Just for the record:
We solved the DynamiteModulesC NPE and Uncaught exception in Firebase runloop (3.0.0) by removing following line
//remove this "feature" if you should use it
FirebaseApp.setAutomaticResourceManagmentEnabled(true)
API description:
If set to true it indicates that Firebase should close database
connections automatically when the app is in the background. Disabled
by default.
(Might be, that we missed some configurations for correct usage of this feature, but App is working as expected after not enabling the ResourceManagment)

Firebase crashes on Android during anonymous login

I am getting this crash in about 70% of devices in the market. However it never came up during testing.
public class MyApp extends Application{
public void onCreate() {
super.onCreate();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseAuth.getInstance().signInAnonymously();
}
}
This is the error.
Fatal Exception: java.lang.RuntimeException: Unable to create application com.mycompany.myapp.activities.MyApp: java.lang.ClassCastException: com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4927)
at android.app.ActivityThread.access$1500(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
at com.google.android.gms.internal.aa.a(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.a(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.d(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.android.gms.internal.z.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.c(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.b(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.b(Unknown Source)
at com.tesseractmobile.solitairesdk.activities.SolitaireApp.onCreate(SolitaireApp.java:123)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4924)
I am using firebase 9.2.1
compile "com.google.firebase:firebase-core:${firebaseVersion}"
compile "com.google.firebase:firebase-database:${firebaseVersion}"
//For dynamic links
compile "com.google.firebase:firebase-invites:${firebaseVersion}"
//Authentication - for logging winning games
compile "com.google.firebase:firebase-auth:${firebaseVersion}"
Right now I am just disabling firebase in our app. We were just testing it to see how stable it is. I have no clue why it worked on all of our test devices then crashed this bad in the wild.
Update:
I was able to get a video of the issue using Firebase Test Lab. It happened when the robotest clicked on an Ad (Ad supported app) then came back to the app. So maybe it has something to do with FirebaseAuth.getInstance().signInAnonymously(); getting called twice? However Application.onCreate() should only be called once. I know there is a known bug with Firebase crash reporting that will cause two Application instances to be created but we are not using that sdk util they fix the issue.
I used Firebase Test Lab to find the issue. It crashed on one of their devices and I watched the video of what happened. Our app is ad supported. We don't click our own ads during testing so this never came up. The crash happens after a user clicks an ad and then reenters the app. The solution I found was the same as this issue. FirebaseApp with name [DEFAULT] doesn't exist
if (!FirebaseApp.getApps(this).isEmpty()){
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseAuth.getInstance().signInAnonymously();
}
I think Application.onCreate() is called more than once. Though that should never happen.
EDIT: THIS ANSWER DOES NOT WORK
After a full week of testing by a 4 person QA team. Running 58 unit and connected tests with espresso on 7 test devices. Then running multiple tests on dozens of cloud devices using Google Test Lab. The problem never happened. Then on release day, 500 crashes in the first half hour!? 70% crash rate. So back to square one.
FINAL ANSWER: Proguard issue
I added these two line to my proguard-rules.pro
#Firebase Authentication
-keepattributes Signature
-keepattributes *Annotation*
Problem solved.
Hi I have a similar problem, after days without solution, I found what it's a version problem with the appcompat, so i Changed this:
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
to this:
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
in the app graddle and my problem solved, sorry for my English
Update your build.gradle:
// Firebase Gradle
compile "com.google.firebase:firebase-auth:9.4.0"
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'

Categories

Resources