Eren Tüfekçi
Eren Tüfekçi

Reputation: 2511

How to handle "Unable to start activity java.util.ConcurrentModificationException"

After updating my app, crashlytics started reporting this issue. with this logcat

androidx.activity.ComponentActivity.onCreate (ComponentActivity.java:149)
androidx.fragment.app.FragmentActivity.onCreate (FragmentActivity.java:313)
androidx.appcompat.app.AppCompatActivity.onCreate (AppCompatActivity.java:106)
com.viyatek.ultimatefacts.Activites.LockScreenActivity.onCreate (LockScreenActivity.java:87)
android.app.Activity.performCreate (Activity.java:7154)
android.app.Activity.performCreate (Activity.java:7145)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1225)

When I look questions with same error code. I saw it causes because of the iteration in lists. In this activity there is no iteration. Even more there is no list or array. So it is not same question with others. The line it says it failed:

 @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState); //(LockScreenActivity.java:87)

    if(new NewVersionControl(this).CheckVersion())
            {
                new NewSharedPrefs(this).LookForNewSharedPrefs();

            handleAlarms = new HandleAlarms(this);
            handleAlarms.SetAlarmManager(); }
        else
        {if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
                this.setShowWhenLocked(true);
            }
            else {            getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
            }

            setContentView(R.layout.opaque_full_screen_lock_screen);

            SharedPrefsHandler sharedPrefsHandler = new SharedPrefsHandler(this);


            //Ads initialized
            MobileAds.initialize(getApplicationContext(), getString(R.string.app_id));

            SdkConfiguration sdkConfiguration =
                    new SdkConfiguration.Builder(getString(R.string.twitter_banner_ad_unit_id)).build();
    MoPub.initializeSdk(this, sdkConfiguration, null);
    Declarations();
    GetRemoteConfig();
    if(handleRealmInit == null) {handleRealmInit = new HandleRealmInit(this);}
    lockScreenRealm = handleRealmInit.GetRealmInstance();
    BindData();
     if(sharedPrefsHandler.GetPref(SharedPrefsHandler.IS_PREMIUM).getIntegerValue()== 0) 
    {
LoadAd();
}
                if(lockScreenFact!= null)   {
                    if(lockScreenFact.isValid())
                    {
                        ReportProperties();
                    }
                }
            }

So I think it occurs due to handling of views or view group by Android. But I couldn't define or reproduce the problem. I am stuck at this point.

Thank you for reading this. Any help is appreciated.

Upvotes: 0

Views: 746

Answers (1)

Lena Bru
Lena Bru

Reputation: 13947

ConcurrentModificationException means you are trying to add/remove elements from an array while iterating over it without an interator.

What is inside your onCreate method ?

Upvotes: 1

Related Questions