Skip to content

ACRA initialization : getting ClassCastException on application update #1233

@razmo51

Description

@razmo51

Describe the bug
When I install my application with ACRA (5.11.0) on a device that had a previous version of my application with a previous version of ACRA (5.9.7), I get a crash on ACRA initialization.

The error is:

            E  ACRA caught a ClassCastException for com.*******
                            java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
                                at android.app.SharedPreferencesImpl.getLong(SharedPreferencesImpl.java:329)
                                at org.acra.startup.LimiterStartupProcessor.processReports(SourceFile:49)
                                at v4.a.run(SourceFile:131)
                                at java.lang.Thread.run(Thread.java:1012)

I think it was caused by a change made a month ago on the LimiterStartupProcessor in this commit:

1bf91f3#diff-0ef0f1b414770d23f2d21a88657bb270f0bc08ec80b25dd1a6caf1d9546fa72a

which replaced the prefs.getInt(...).toLong() by prefs.getLong(...), the previous value (from older ACRA version) was indeed an java.lang.Integer and cannot be casted to a java.lang.Long

The workaround I found was to change the sharedPreferencesName on the Core config so the previous value is not used.

(I'm sorry I didn't have time to enable ACRA.DEBUG. I worked around the error as my work load is high at the moment, I needed to find a quick solution)

Expected behavior
ACRA initialization without crash

Version

  • Android: 12
  • ACRA: 5.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions