Question

I am using ACRA to get Crash Reports and my apps are crashing with the following error.

java.lang.IllegalStateException: ACRA#init called more than once
    at org.acra.ACRA.init(ACRA.java:121)
    at com.m7.nomad.NomadApplication.onConfigurationChanged(NomadApplication.java:15)
    at android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:3515)
    at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:3655)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1128)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:150)
    at android.app.ActivityThread.main(ActivityThread.java:4369)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:846)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
    at dalvik.system.NativeStart.main(Native Method)

Any idea how i can solve this issue ?

Was it helpful?

Solution

I think it's quite explicit => ACRA.init method is called twice (or more)

Why did you initialize ACRA in onConfigurationChanged method ?

onConfigurationChanged is called each time your configuration is changed (good deduction Dr Watson...): for example when you change the orientation of your handset, ...

You should initialize ACRA in your Application.onCreate method (which is called only once):

public class MyApplication extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    ACRA.init(this);
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top