My application keeps crash report on Crashlytics for ArrayIndexOutOfBoundsException at com.huawei.agconnect.crash.internal.log.h$b.read. I've tried to search around but doesn't seems to get any info on this.
For my recent release, I update my agconnect libraries but still getting this crash. Here are the versions:
build.gradle project
classpath 'com.huawei.agconnect:agcp:1.7.2.300'
build.gradle app
implementation 'com.huawei.hms:base:6.6.0.300'
implementation 'com.huawei.agconnect:agconnect-core:1.7.2.300'
implementation 'com.huawei.hms:hianalytics:6.7.0.300'
implementation 'com.huawei.agconnect:agconnect-crash:1.7.2.300'
implementation 'com.huawei.hms:push:6.7.0.300'
implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.7.2.300'
From the report, all crashes are for Huawei devices and 90%+ are Android 10. The rest are Android 11.
This is the stacktrace shown in Crashlytics:
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException:
at com.huawei.agconnect.crash.internal.log.h$b.read(:51)
at com.huawei.agconnect.crash.internal.log.e$1.a(:15)
at com.huawei.agconnect.crash.internal.log.h.a(:21)
at com.huawei.agconnect.crash.internal.log.e.a(:28)
at com.huawei.agconnect.crash.internal.log.f.b(:8)
at com.huawei.agconnect.crash.internal.log.d.a(:215)
at com.huawei.agconnect.crash.internal.log.c.a(:10)
at com.huawei.agconnect.crash.internal.log.a$4.run(:6)
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:929)
Not exactly sure, but this line appears questionable to me:
implementation 'com.huawei.hms:base:6.6.0.300'
base should use the same HMS version 6.7.0.300, alike the other libraries.
If not, the only chance to pinpoint this is to check out the decompiled class com.huawei.agconnect.crash.internal.log.h$b.read at line 51 (give or take).
This would at least provide a clue, which array it tries to access there ...
Try to update all Huawei dependencies to 6.7.0.300 vesion.
After 1 month or so update to the latest Huawei Agconnect, I no longer receiving this crash report. Now this is the version I'm using:
implementation 'com.huawei.hms:base:6.8.0.300'
implementation 'com.huawei.agconnect:agconnect-core:1.7.3.300'
implementation 'com.huawei.hms:hianalytics:6.8.0.300'
implementation 'com.huawei.agconnect:agconnect-crash:1.7.3.300'
implementation 'com.huawei.hms:push:6.7.0.300'
implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.7.3.300'
Following are the dependencies added in pubspec.yaml
firebase_core: ^0.5.2
firebase_auth: ^0.18.3
firebase_crashlytics: ^0.2.3
I update the gradle-wrapper.properties like this: as seen somewhere as a solution to below issues.
distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-all.zip
Firebase console shows the successful installation as below
Still we are getting below
E/AndroidRuntime(10914): java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.IllegalStateException: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
E/AndroidRuntime(10914): at android.app.ActivityThread.installProvider(ActivityThread.java:6905)
E/AndroidRuntime(10914): at android.app.ActivityThread.installContentProviders(ActivityThread.java:6497)
E/AndroidRuntime(10914): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6437)
E/AndroidRuntime(10914): at android.app.ActivityThread.access$1800(ActivityThread.java:229)
E/AndroidRuntime(10914): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1898)
E/AndroidRuntime(10914): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(10914): at android.os.Looper.loop(Looper.java:148)
E/AndroidRuntime(10914): at android.app.ActivityThread.main(ActivityThread.java:7402)
E/AndroidRuntime(10914): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10914): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
E/AndroidRuntime(10914): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Please advice.
I had a similar issue just now, but by following the steps in 'Upgrade to the Firebase Crashlytics SDK' managed to fix this.
Basically, you need to add the following to your build.gradle file in the android folder, in the dependencies section:
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
Then in the app level build.gradle, where you've already added com.google.gms.google-services previously, add:
apply plugin: 'com.google.firebase.crashlytics'
Finally, in the dependencies section in the same file, add:
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
This should now work. This is assuming you don't have any of the Fabric repository stuff in there, which you'll need to remove. The details are in that link.
I'm using the latest firebase(9.0.2):
build.gradle:
dependencies {
...
compile "com.google.firebase:firebase-database:9.0.2"
compile 'com.google.firebase:firebase-auth:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
Project build.gradle
classpath 'com.google.gms:google-services:3.0.0'
And after some time application starts crashing with this Exception:
Fatal Exception: java.lang.RuntimeException: Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
at com.google.android.gms.internal.zzadp$1$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5274)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by java.lang.AssertionError: hardAssert failed:
at com.google.android.gms.internal.zzaiv.zzb(Unknown Source)
at com.google.android.gms.internal.zzaiv.zzaN(Unknown Source)
at com.google.android.gms.internal.zzagh.zzb(Unknown Source)
at com.google.android.gms.internal.zzagh.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzadp.zza(Unknown Source)
at com.google.android.gms.internal.zzaeu.zzic(Unknown Source)
at com.google.android.gms.internal.zzafc.zzRy(Unknown Source)
at com.google.android.gms.internal.zzafc.zza(Unknown Source)
at com.google.android.gms.internal.zzafc$1.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
in onCreate of Application I have:
#Override
public void onCreate() {
...
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
}
and also we created singleton helper class for Firebase what called from Activities(all activities in the same process)/Fragments:
private FirebaseHelper() {
mFirebaseRef = FirebaseDatabase.getInstance().getReference();
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseAuth.addAuthStateListener(this);
authentication();
}
public static synchronized FirebaseHelper getInstance() {
if (mInstance == null || mInstance.getFirebaseRef() == null) {
mInstance = new FirebaseHelper();
}
return mInstance;
}
Libraries:
dependencies {
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.5.6#aar') {
transitive = true;
}
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-annotations:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.google.android.gms:play-services-base:9.0.2'
compile 'com.google.android.gms:play-services-maps:9.0.2'
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.google.android.gms:play-services-appindexing:9.0.2'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.11.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.amazonaws:aws-android-sdk-core:2.2.12'
compile 'com.amazonaws:aws-android-sdk-cognito:2.2.12'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.5'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.github.curioustechizen.android-ago:library:1.3.0'
compile 'com.cedarsoftware:json-io:4.4.0'
compile 'com.timehop.stickyheadersrecyclerview:library:0.4.3#aar'
compile 'joda-time:joda-time:2.9.3'
compile 'com.facebook.fresco:fresco:0.10.0'
compile 'com.facebook.fresco:imagepipeline-okhttp3:0.10.0'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-invites:9.0.2'
compile 'com.google.firebase:firebase-database:9.0.1'
compile 'com.google.firebase:firebase-auth:9.0.1'
compile 'com.github.jd-alexander:LikeButton:0.2.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
compile files('libs/core-3.2.1.jar')
}
UPDATE: It turns out there's another cause of this symptom, as mentioned by Kristijan in the comments. We've identified a bug where if you have a startAt() or endAt() call with an integer endpoint, e.g. startAt(10), it can trigger this sort of cache corruption. This bug will be fixed in the next release of the SDK. In the meantime, you may be able to use non-integer endpoints, e.g. startAt(10.001), as a workaround.
These symptoms match a known limitation with Firebase Realtime Database that prevents it from working if you have persistence enabled in multiple processes in an Android app.
Note that any Application.onCreate() code will run for every process in a multi-process android app, and so if your app is multi-process, you are initializing Firebase Database with persistence enabled in multiple processes and this is liable to lead to corruption of our offline cache and the hardAssert error that you are reporting.
Keep in mind that sometimes your app may be multi-process without you realizing it. For instance if you're using firebase-crash, it currently creates a background process for the purpose of reporting crashes more reliably, and so if you use firebase-crash, you now have a multi-process app. Other 3rd-party libraries could have similar behavior.
To test, you could add code to your Application.onCreate() something like:
System.out.println('INITIALIZING APP FROM PID: ' + android.os.Process.myPid());
If you see that logged twice in logcat (with two different PIDs) that means your app is running with multiple processes and you're hitting the limitation I mentioned.
As a workaround, you can either:
Modify your app so that it only uses a single process.
Remove your setPersistenceEnabled() code from your Application class and put it somewhere that will only be executed in your main process.
Note that you'll likely need to clear your app data to get rid of the hardAssert error once you've hit it, as the error indicates that the offline cache has gotten into an invalid state, so to fix it, you must clear it completely.
In an upcoming release, we have added better detection of this scenario so you'll get a much better error message. Additionally, firebase-crash will in the future avoid spawning a 2nd process, which may make this less likely to be an issue.
I know it is an old post , i faced this issue and after some research , i upgraded my gradle to :
implementation 'com.google.firebase:firebase-database:18.0.1'
This helped the error go away. use the latest library.
This Solved My Problem.
We are facing the same issue on version 9.0.2 and 9.2.0. After many hours of investigation, we found that one way to reproduce this issue is to have a query with fixed endAt and startAt parameters. Let me explain with a sample code:
// Firebase dependencies
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-database:9.2.0'
...
public class MainActivity extends AppCompatActivity {
private FirebaseDatabase m_Database;
private static boolean s_persistenceInitialized = false;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
m_Database = FirebaseDatabase.getInstance();
if (!s_persistenceInitialized) {
m_Database.setPersistenceEnabled(true);
s_persistenceInitialized = true;
}
m_Database.setLogLevel(Level.DEBUG);
}
#Override
protected void onStart() {
super.onStart();
long endAt = 100L; // Fixed value: CRASH on third app restart
// long endAt = new Date().getTime(); // Dynamic value: NO CRASH
getGoal("min_per_day", endAt, "some_uid");
}
private void getGoal(String p_goalId, long p_endAt, String p_uid) {
Query ref = m_Database.getReference("v0/data/meditation/goals").child(p_goalId).child(p_uid)
.orderByChild("time").endAt(p_endAt).limitToLast(1);
ref.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i("FB", "Snapshot: " + dataSnapshot);
}
#Override
public void onCancelled(DatabaseError error) {
Log.e("FB", "Error: " + error);
}
});
}
}
So the fixed endAt param will crash the app on third start. I assume queries are cached to disk and then corrupted at some point if we recreate the same query from local cache multiple times (three). On the other hand, if endAt is not fixed, for example current time in millis, then everything works as expected. The same applies for startAt query parameter.
I too faced the same issue; After some point of time application was keep crashing on every launch.
For time being I've disabled this database persistance. FirebaseDatabase.getInstance().setPersistenceEnabled(true).
I don't see any such strange crashes now!
Hope Firebase team will resolve this issue soon.
This issue has been fixed in version 9.6. Check out the release notes.
However, when we enable the offline capabilities internet connection is still required for our app. Otherwise, write (at least) callbacks are never called.
Just for the record:
We solved the 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)
This fault is not from firebase, i simply got mine fixed by solving an uncaught NullPointerException in my program. Because when it throws an Exception while currently using firebase library, it misleads to firebase AssertionError.
You need to debug your project carefully to solve this problem.
And this seem to be compiler issue. However, you should try downgrading your Android Gradle Plugin to match the expected firebase library version i suspect.
I have this problem, this method work if the install is new, and this method work if put the code how:
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseDatabase database = FirebaseDatabase.getInstance();
But if test in other device you need uninstall the app
AndroidRuntime: FATAL EXCEPTION: pool-5-thread-1
Process: com.stemdot.chopesdriver, PID: 29923
java.lang.AbstractMethodError: abstract method "void com.google.firebase.iid.zzb.handleIntent(android.content.Intent)"
at com.google.firebase.iid.zzb$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
I had the same problem. You should keep google play service version the same as firebase messaging and firebase core version.
I've had the same problem. I followed the FCM tutorial and got this exception. I fixed this error by changing the firebase-messaging lib to the latest version in the gradle file.
When I copied from the tutorial, it was:
compile 'com.google.firebase:firebase-messaging:10.0.1'
I changed it to the latest version as of now and everything works:
compile 'com.google.firebase:firebase-messaging:11.0.1'
Add these three lines in gradle...
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile("com.google.android.gms:play-services-gcm:10.2.1")
I am developing an android app using Android Studio and got the message today that there is a new version of Google Play services.
I am using Google play services analytics, ads and tag manager. As well as Firebase analytics/messaging/crash.
The version I had in my build.gradle was 10.0.1 and the new version is 10.2.0
But when I change it, the app crashes on start with:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sega.segaid, PID: 15749
java.lang.NoSuchMethodError: com.google.android.gms.internal.zzaac.zza
at com.google.firebase.FirebaseApp.zzcl(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4964)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4559)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4499)
at android.app.ActivityThread.access$1600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5191)
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:810)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Is this an error on my side? It crashes before the app even starts. The only thing I changed is updating the used dependencies of the play services and firebase.
The last time something like that happened, it was a bug in Firebase, which was fixed by Google after some days.
EDIT:
build.gradle dependencies
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v13:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.android.gms:play-services-base:10.2.0'
compile 'com.google.android.gms:play-services-tagmanager:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-analytics:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
SOLUTION:
I cleared all caches and also added the version as def instead if writing it out each time. It worked now. Thank you everyone.
I picked the answer by rencsaridogan as solution because I think I forgot to update one of the libraries at my first try and the def is really helpful there. But I also needed to clear caches (as recommended by Avi in the comments below).
There are 2 important things about Google Play Services and Firebase usage as stated in official documentation.
You need to declare the latest classpath of Google Play Services in your root-level gradle, example quoted from given documentation:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
Also, as comments suggest in your project every Google Play Services and Firebase package has to have same version, to ensure this you can follow the method given below (It'll be easier like this, you only need to update version number on definitions)
def googlePlayLibVersion = "10.2.0"
def googleFirebaseLibVersion = "10.2.0"
ext {
annotations = "com.android.support:support-annotations:${supportLibVersion}"
firebaseAnalytics = "com.google.firebase:firebase-core:${googleFirebaseLibVersion}"
firebaseCrash = "com.google.firebase:firebase-crash:${googleFirebaseLibVersion}"
googlePlayAds = "com.google.android.gms:play-services-ads:${googlePlayLibVersion}"
googlePlayGcm = "com.google.android.gms:play-services-gcm:${googlePlayLibVersion}"
googlePlayAnalytics = "com.google.android.gms:play-services-analytics:${googlePlayLibVersion}"
}