Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access ErrorReporter before ACRA#init #622

Closed
greenscreens-io opened this issue Jan 9, 2018 · 3 comments
Closed

Cannot access ErrorReporter before ACRA#init #622

greenscreens-io opened this issue Jan 9, 2018 · 3 comments

Comments

@greenscreens-io
Copy link

Error occurs after starting application again after crash.

Here is initialization and error log.

@AcraCore(reportFormat = StringFormat.JSON, buildConfigClass = BuildConfig.class )
@AcraHttpSender(
        httpMethod = HttpSender.Method.POST,
        uri = R.string.acra_url)
@AcraToast(
        resText = R.string.crash_toast_text
)
@AcraDialog(
        resText = R.string.crash_dialog_text,
        resTheme = R.style.AppTheme_Dialog,
        resIcon = android.R.drawable.ic_dialog_info,
        resTitle = R.string.crash_dialog_title,
        resCommentPrompt = R.string.crash_dialog_comment_prompt
)
public class App extends Application {

    @Override
    protected void attachBaseContext(final Context base) {
        super.attachBaseContext(base);
  
        final String uuid = Preferences.getUUID(app);

        ACRA.DEV_LOGGING = Constants.DEBUG;
        ACRA.init(this);
        ACRA.getErrorReporter().putCustomData("AppUUID", uuid);
 
    }
}
01-08 16:43:22.535 5575-5575/io.greenscreens.terminal:acra E/AndroidRuntime: FATAL EXCEPTION: main
  Process: io.greenscreens.terminal:acra, PID: 5575
  java.lang.RuntimeException: Unable to instantiate application io.greenscreens.terminal.App: java.lang.IllegalStateException: Cannot access ErrorReporter before ACRA#init
      at android.app.LoadedApk.makeApplication(LoadedApk.java:601)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4915)
      at android.app.ActivityThread.access$1500(ActivityThread.java:144)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:155)
      at android.app.ActivityThread.main(ActivityThread.java:5696)
      at java.lang.reflect.Method.invoke(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:372)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
   Caused by: java.lang.IllegalStateException: Cannot access ErrorReporter before ACRA#init
      at org.acra.ACRA.getErrorReporter(ACRA.java:280)
      at io.greenscreens.terminal.App.attachBaseContext(App.java:67)
      at android.app.Application.attach(Application.java:190)
      at android.app.Instrumentation.newApplication(Instrumentation.java:1002)
      at android.app.Instrumentation.newApplication(Instrumentation.java:986)
      at android.app.LoadedApk.makeApplication(LoadedApk.java:587)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4915) 
      at android.app.ActivityThread.access$1500(ActivityThread.java:144) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:155) 
      at android.app.ActivityThread.main(ActivityThread.java:5696) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:372) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) 
@MFlisar
Copy link

MFlisar commented Jan 9, 2018

I've had this issue as well, you need to use following before accessing the error reporter:

ACRA.init(app, config);
if (!ACRA.isACRASenderServiceProcess()) {
	ACRA.getErrorReporter()....
}

Because the error reporter is not initialised in the crash service process. It was also added to the docs in the meantime I think

@greenscreens-io
Copy link
Author

All I've found is this, but it was not so clear what to do with it
https://github.com/ACRA/acra/wiki

Your answer was helpful, thank you. It is working now.

@F43nd1r
Copy link
Member

F43nd1r commented Jan 9, 2018

5.0.1 will not crash anymore with this call (it'll warn instead). Also, the message was improved. See #616

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants