question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ACRA.init(this) crashing when trying to convert unsent reports

See original GitHub issue

I’m having an issue where my app is failing to start (repeatedly crashing) after a crash. So far, I found that the problem is during initialization, ACRA is trying to convert unsent reports to JSON, when they are already JSON. This makes the ReportConverter#legacyLoad() parser fail, and crash the whole app.

ACRA version is last stable 4.9.2. App installation is fresh (i.e. not an app that was using an old version of ACRA and got updated to 4.9.2).

The configuration in the Application class:

@ReportsCrashes(
        httpMethod = HttpSender.Method.PUT,
        reportType = HttpSender.Type.JSON,
        formUri = Constants.ACRA_FORM_URI,
        formUriBasicAuthLogin = Constants.ACRA_FORM_URI_BASICAUTHLOGIN,
        formUriBasicAuthPassword = Constants.ACRA_FORM_URI_BASICAUTHPASSWORD,
        mode = ReportingInteractionMode.SILENT)

In the shared preferences:

$ more xxx_preferences.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
    <boolean name="acra.legacyAlreadyConvertedTo4.8.0" value="true" />
</map>

Notice there is no acra.legacyAlreadyConvertedToJson preference.

Stack trace (some identifiers changed for privacy):

02-22 11:13:06.527 8774-8774/? E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.XXX.XXX.XXX, PID: 8774
 java.lang.RuntimeException: Unable to create application com.XXX.xxx.XXX.application.XXXApplication: java.lang.IllegalArgumentException: No enum constant org.acra.ReportField.{"LOGCAT"
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5406)
     at android.app.ActivityThread.-wrap2(ActivityThread.java)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:154)
     at android.app.ActivityThread.main(ActivityThread.java:6119)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
  Caused by: java.lang.IllegalArgumentException: No enum constant org.acra.ReportField.{"LOGCAT"
     at java.lang.Enum.valueOf(Enum.java:254)
     at org.acra.legacy.ReportConverter.legacyLoad(ReportConverter.java:297)
     at org.acra.legacy.ReportConverter.convert(ReportConverter.java:77)
     at org.acra.legacy.LegacyFileHandler.updateToCurrentVersionIfNecessary(LegacyFileHandler.java:51)
     at org.acra.ACRA.init(ACRA.java:236)
     at org.acra.ACRA.init(ACRA.java:173)
     at org.acra.ACRA.init(ACRA.java:157)
     at org.acra.ACRA.init(ACRA.java:140)
     at com.XXX.xxx.XXX.application.XXXApplication.onCreate(XXXApplication.java:112)
     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
     at android.app.ActivityThread.-wrap2(ActivityThread.java) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:154) 
     at android.app.ActivityThread.main(ActivityThread.java:6119) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

The file which is trying to be converted is in app_ACRA-unapproved/2017-02-21T17:16:28.598+01:00-IS_SILENT.stacktrace, and seems a well-formed JSON file, but debugging the ReportConverter#legacyLoad() I can see the following:

{"LOGCAT""02-21 17:16:28.280 D/debuglogger(13715): [DEBUG] WMAuthActionContext#executeAction(WMAuthActionContext.java:55) - executeAction - callback failure with error status: 401 
... (all logcat data omitted)
	at java.lang.Thread.run(Thread.java:761)
","PHONE_MODEL":"Nexus 5X","TOTAL_MEM_SIZE":11454181376... (continues)

I think this last part is not relevant, as is trying to parse a JSON crash report as the legacy format, which from what I understand is key=value.

Another important bit of information is, currently the files (crash reports) present in the application are as follow:

$ ls app_ACRA-*
app_ACRA-approved:

app_ACRA-unapproved:
2017-02-21T17:16:28.598+01:00-IS_SILENT.stacktrace

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
F43nd1rcommented, Feb 22, 2017

You’re right, preference reset is a situation we have to account for.

0reactions
F43nd1rcommented, Apr 6, 2017

I don’t think configuration migration is in the scope of the project. But you could easily roll your own solution by migrating all keys starting with acra. to the new preferences right before the init call.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate crash reports to ACRA (!140) · Merge requests · briar / briar ...
Here's an alternate idea for UX: Crash happens. CrashReportActivity starts. A dialog immediately appears asking whether the user wants to review and send...
Read more >
Emailing Reports using ACRA(ver 5.7.0) on Android not working
Im trying to capture the crash logs and send it via mail using ACRA. ... ACRA : ACRA is enabled for com.example.myapplication, initializing....
Read more >
acra - Google Code
ID Status Summary 155 New g Type‑Defect Priority‑Medium 154 New Is it ACRA coding Bug? Type‑Defect Priority‑Medium 151 New Acra android Type‑Defect Priority‑Medium
Read more >
org.acra.file.CrashReportPersister.<init> java code examples ...
if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Writing crash report file " + file); final CrashReportPersister persister = new CrashReportPersister();
Read more >
Index (Application Crash Report for Android 4.9.0 API)
Use this class to initialize the crash reporting feature using ACRA.init(Application) as soon as possible in your Application subclass Application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found