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

ACRA initialization : getting ClassCastException on application update #1233

Closed
razmo51 opened this issue Aug 10, 2023 · 3 comments
Closed
Labels

Comments

@razmo51
Copy link

razmo51 commented Aug 10, 2023

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
@mikehardy
Copy link
Contributor

Just a note: this appeared to pop up again though we have released acra 5.11.1 in the version of the app that we saw it in 🤔

Current untested thought (from the comment in our related issue):

Current possibility: is the code in c193e35 catching the Kotlin ClassCastException, and does this also handle java.lang.ClassCastException

@F43nd1r
Copy link
Member

F43nd1r commented Aug 30, 2023

@mikehardy kotlin ClassCastException is a typealias for java.lang, so that's not it. Do you have a stacktrace?

@F43nd1r F43nd1r reopened this Aug 30, 2023
@F43nd1r
Copy link
Member

F43nd1r commented Aug 30, 2023

I had a look at your linked issue, and it seems to be the other way around (long cast to integer) compared to this issue (int cast to long)

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

No branches or pull requests

3 participants