52

In a recent release where I added MoPub via Admob ad mediation I am seeing a bunch of ConcurrentModificationException in crash logs. It all seems to be native code and I am on the latest version of all ad related and google/android related libraries. Anyone run in to this before?

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3121)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3264)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1955)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:214)
  at android.app.ActivityThread.main (ActivityThread.java:7078)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:964)
Caused by: java.util.ConcurrentModificationException: 
  at androidx.c.g.put (SimpleArrayMap.java:482)
  at com.google.android.gms.measurement.internal.hs.a
  at com.google.android.gms.measurement.internal.hi.onActivityCreated
  at android.app.Application.dispatchActivityCreated (Application.java:245)
  at android.app.Activity.onCreate (Activity.java:1108)
  at androidx.core.app.e.onCreate (ComponentActivity.java:81)
  at androidx.activity.b.onCreate (ComponentActivity.java:149)
  at androidx.fragment.app.c.onCreate (FragmentActivity.java:313)
  at androidx.appcompat.app.e.onCreate (AppCompatActivity.java:106)
  at com.teamtol.livedota.BaseActivity.onCreate (BaseActivity.java:21)
  at com.teamtol.livedota.RecentGameActivity.onCreate (RecentGameActivity.java:70)
  at android.app.Activity.performCreate (Activity.java:7327)
  at android.app.Activity.performCreate (Activity.java:7318)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1275)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3101)

This is what the code looks like up to line 21 of BaseActivity:

protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        super.onCreate(savedInstanceState);

This is what the code looks like up to line 70 of RecentGameActivity

public class RecentGameActivity extends BaseActivity implements AdapterView.OnItemSelectedListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
mburst
  • 531
  • 4
  • 7

5 Answers5

25

In our case, we are only seeing the crash with

com.google.firebase:firebase-analytics:17.2.2 

reverting to 17.2.1 has fixed the problem

This happens too if you are using firebase-core:17.2.2, because firebase-analytics is the same library rebranded. Take into account that as per official docs, current usage of firebase-core is deprecated -> https://firebase.google.com/support/release-notes/android#latest_sdk_versions

Pablo A. Martínez
  • 2,547
  • 2
  • 23
  • 28
  • reverting firebase-analytics to 17.2.1 has fixed our problem. Thanks! – Jaydipsinh Zala Feb 03 '20 at 05:31
  • Reverting firebase-analytics to 17.2.1 has not fixed the problem for us. We've been using `17.2.1` for a while and did not see these crashes. I doubt that the crash is at all related to the `firebase-analytics` library. – Manuel Feb 03 '20 at 15:53
  • 1
    Thanks for the heads up. I just released a version with 17.2.1. Will update once it's had time in users' hands – mburst Feb 04 '20 at 15:52
  • Correction: we reverted firebase-analytics to 17.2.1 but left firebase-core unchanged at 17.2.2 and were still receiving crashes. We then released a version with core also reverted to 17.2.1 and no crashes so far. (I am not sure firebase-core is still needed at all?) – Manuel Feb 04 '20 at 19:50
  • @PabloA.Martínez Good, we did not see any crashes on 17.2.1 since reverting both core and analytics libraries. Do you happen to know since which version core is deprecated? I couldn’t find a reference to that. – Manuel Feb 05 '20 at 08:24
  • I changed firebase-core to firebase-analytics 17.2.1 (was a simple name change for me no code changes required) and have no issues now. Thanks for the help! – mburst Feb 07 '20 at 02:45
  • i dont import firebase-analytics nor firebase-core and im getting the same error – Rafael Lima Feb 07 '20 at 06:03
  • Can someone confirm if its fixed in 17.2.3 released on the 28th Feb? – Tearsdontfalls Mar 01 '20 at 17:59
  • @Tearsdontfalls I would suggest waiting a bit more, due to known issues found in some updated dependencies last 27th Feb https://firebase.google.com/support/release-notes/android – Pablo A. Martínez Mar 03 '20 at 06:39
20

Revert your Firebase Core library to:

implementation 'com.google.firebase:firebase-core:17.1.0'

I've seen this crash on both v17.2.1 and v17.2.2, but since reverting to 17.1.0 all has been fine.

I've reported the bug here: https://firebase.google.com/support/troubleshooter/report/bugs

Update

Thanks @Sébastien, reverting to v17.2.0 should also work:

implementation 'com.google.firebase:firebase-core:17.2.0'
Jim
  • 586
  • 4
  • 10
  • 2
    In the Firebase Release Notes (https://firebase.google.com/support/release-notes/android) they say to replace the firebase-core by firebase-analytics or the libraries that we are using. Have you tried this solution? – Adelino Jan 27 '20 at 13:16
  • 2
    I guess both are almost identical except the title. We found that issue when upgrading from com.google.firebase:firebase-analytics:17.1.0 to 17.2.2 – Farasy Jan 27 '20 at 13:48
  • @Farasy thanks for the reply, I will revert the dependency :| – Adelino Jan 27 '20 at 15:37
  • 1
    Thanks @Jim. Please keep us posted. It seems that `com.google.firebase:firebase-core:17.2.0` is also exempt of the bug. – Sébastien Jan 27 '20 at 15:37
  • @Sébastien thanks for the info, I'll update my answer to reflect that firebase-core:17.2.0 also works. I had skipped that version altogether and went back to the version that had previously worked for us. – Jim Jan 27 '20 at 18:39
  • 1
    Version 17.2.1 also works, we did not ever observe a crash on that version, only after upgrading to 17.2.2. – Manuel Feb 03 '20 at 10:28
  • 17.2.1 is working for me, but I wouldn't blame anyone for reverting back to 17.1.x or 17.2.0. Thanks for the help! – mburst Feb 07 '20 at 02:47
  • i dont import firebase-analytics nor firebase-core and im getting the same error – Rafael Lima Feb 07 '20 at 06:03
  • I import 17.2.2 ads and firebase-analytics, getting ConcurrentModificationException in com.google.android.gms.measurement.internal.zzin.zza + 108(com.google.android.gms:play-services-measurement-impl@@17.2.2:108 – Dmitrijs Feb 10 '20 at 12:13
  • 2nd possible solution is to delay measurement initialization with meta-data https://developers.google.com/admob/android/eu-consent#delay_app_measurement_optional – Dmitrijs Feb 10 '20 at 12:48
  • Can't reproduce the exception but it started to show up on google play crash reports after upgraded from firebase-core:17.2.1 to firebase-core:17.2.2. So instead downgrading to 17.2.1 I'll give a try to @Dmitrijs delay measurement initialization solution. – Sinan Ceylan Feb 15 '20 at 21:07
  • @SinanCeylan I delay measurement initialization and downgraded firebase-analytics to 17.2.0, also added play-services-measurement and play-services-measurement-sdk to Gradle to have an exact version of it - 17.1.0, now crash completely gone. – Dmitrijs Feb 16 '20 at 09:06
  • Fixed on 17.2.3 https://firebase.google.com/support/release-notes/android#analytics_v17-2-3 – Sinan Ceylan Mar 11 '20 at 22:50
11

It is finally fixed in 17.2.3: https://firebase.google.com/support/release-notes/android#analytics_v17-2-3

Mateusz Pryczkowski
  • 1,874
  • 1
  • 16
  • 20
6

We've identified the issue, and are working on a fix for the next release of the SDK.

Eric Burley
  • 576
  • 2
  • 3
0

We have recently encountered a similar problem. Error in the Unity Ads adapter for Admob mediation.

Here is our build.gradle file:

implementation 'com.google.android.gms:play-services-ads:19.1.0'
implementation 'com.google.ads.mediation:unity:3.4.2.1'
implementation 'com.google.ads.mediation:vungle:6.5.3.0'
implementation 'com.google.ads.mediation:chartboost:7.5.0.0'
implementation 'com.google.ads.mediation:mytarget:5.6.3.0'
implementation 'com.yandex.android:mobmetricalib:3.13.1'
implementation 'com.yandex.android:mobileads:2.142'
implementation 'com.yandex.ads.adapter:admob-mobileads:0.3.0'

implementation 'com.google.android.gms:play-services-games:19.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-dynamic-links:19.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

implementation 'com.google.android.play:core:1.7.2'
implementation 'androidx.multidex:multidex:2.0.1'

Error in Google Play console:

java.util.ConcurrentModificationException: 
  at java.util.HashMap$HashIterator.nextNode (HashMap.java:1453)
  at java.util.HashMap$EntryIterator.next (HashMap.java:1487)
  at java.util.HashMap$EntryIterator.next (HashMap.java:1485)
  at com.google.ads.mediation.unity.UnitySingleton$UnitySingletonListener.onUnityAdsError (UnitySingleton.java:227)
  at com.unity3d.services.ads.configuration.AdsModuleConfiguration$3.run (AdsModuleConfiguration.java:92)
  at android.os.Handler.handleCallback (Handler.java:888)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:213)
  at android.app.ActivityThread.main (ActivityThread.java:8178)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)

Is this problem related to firebase again?

UPDATE

It looks like the problem this time is in the UnityAds adapter: https://developers.google.com/admob/android/mediation/unity#version-3.4.2.2

denri11
  • 63
  • 5