ACRA.init(this) crashing when trying to convert unsent reports
See original GitHub issueIssue Description
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:
- Created 6 years ago
- Comments:8 (4 by maintainers)
You’re right, preference reset is a situation we have to account for.
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 theinit
call.