java.util.ConcurrentModificationException in activity onCreate

2022-08-31 20:40:07

在最近的一个版本中,我通过Admob广告中介添加了MoPub,我在崩溃日志中看到了一堆ConcurrentModificationException。这一切似乎都是原生代码,我正在使用所有广告相关和Google / Android相关库的最新版本。以前有人碰到这个吗?

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)

这是代码在 BaseActivity 的第 21 行之前的样子:

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

这是代码在最近的游戏活动的第70行的样子

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

答案 1

在我们的例子中,我们只看到崩溃

com.google.firebase:firebase-analytics:17.2.2 

恢复到 17.2.1 已修复问题

如果您使用的是 firebase-core:17.2.2,也会发生这种情况,因为 firebase-analytics 是同一个重新命名的库。考虑到根据官方文档,firebase-core的当前用法已被弃用 - >https://firebase.google.com/support/release-notes/android#latest_sdk_versions


答案 2

将您的 Firebase 核心库恢复为:

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

我在v17.2.1和v17.2.2上都看到了这种崩溃,但是自从恢复到17.1.0以来,一切都很好。

我在这里报告了这个错误:https://firebase.google.com/support/troubleshooter/report/bugs

更新

感谢@Sébastien,恢复到v17.2.0也应该有效:

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

推荐