简体   繁体   中英

Why is enableCrashReporting() being called multiple times?

One of my apps with considerable audience has the following error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.karlol.modernoapp/com.identifier.myapp.MainActivity}: java.lang.RuntimeException: enableCrashReporting() called multiple times.

The parse enableCrashReporting() method is only called once in onCreate() just like this:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ParseCrashReporting.enable(this);
    Parse.initialize(this, "parse key", "another parse key");   
}

Caused by: java.lang.RuntimeException: enableCrashReporting() called multiple times.

I'm seeing this error in Parse Crash Reporting platform, about 16 occurrences right now, only 1 supposed happen to me but I didn't remember, when I run the app a thousand times, I can't find the error.

Am I correctly calling the enableParseReporting() method? Do I have to check if the method has been called already to not call it again?

Activity's onCreate() will be called every time you change the activity and come back. Unless you handle configuration changes it will also be called when rotating the screen, because Activity is killed and recreated then.

Consider creating a class that extends Application and call that initialization in the Applications onCreate(). This will be called only when your any of your app components is started at the beginning of app lifecycle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM