Vorlonsoft / AndroidRate

AndroidRate is a library to help you promote your Android app by prompting users to rate the app after using it for a few days.
https://vorlonsoft.github.io/AndroidRate/
MIT License
136 stars 34 forks source link

NumberFormatException occuring on startup #26

Open T-Spoon opened 2 years ago

T-Spoon commented 2 years ago

It seems like recently we've been getting NumberFormatException errors when starting the app and initializing AndroidRate. I'll need to do further investigation but here's an (obfuscated) stack trace in case someone else bumps into this:

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3840)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4016)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2325)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:247)
  at android.app.ActivityThread.main (ActivityThread.java:8656)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.NumberFormatException: 
  at java.lang.Integer.parseInt (Integer.java:615)
  at java.lang.Short.parseShort (Short.java:118)
  at java.lang.Short.valueOf (Short.java:174)
  at java.lang.Short.valueOf (Short.java:200)
  at com.vorlonsoft.android.rate.h.b (SourceFile:12)
  at com.vorlonsoft.android.rate.a.e (SourceFile:1)
  at com.vorlonsoft.android.rate.a.T (SourceFile:7)
  at com.vorlonsoft.android.rate.a.V (SourceFile:1)
  at com.xxx.xxx.xxx.XXActivity.onCreate (SourceFile:17)
  at android.app.Activity.performCreate (Activity.java:8215)
  at android.app.Activity.performCreate (Activity.java:8199)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1309)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3813)

Clearing the app data appears to fix it - I assume some dodgy value is being stored by AppRate and re-parsing it causes a crash.

T-Spoon commented 1 year ago

This issue popped up again so thought I'd revisit my old issue!

Deobfuscated stack trace in case anyone has the same problem:

Caused by java.lang.NumberFormatException
For input string: "6y0-1"
java.lang.Integer.parseInt (Integer.java:747)
java.lang.Short.parseShort (Short.java:120)
java.lang.Short.valueOf (Short.java:176)
java.lang.Short.valueOf (Short.java:202)
com.vorlonsoft.android.rate.PreferenceHelper.get365DayPeriodDialogLaunchTimes (PreferenceHelper.java:139)
com.vorlonsoft.android.rate.AppRate.isBelow365DayPeriodMaxNumberDialogLaunchTimes (AppRate.java:113)
com.vorlonsoft.android.rate.AppRate.shouldShowRateDialog (AppRate.java:360)
com.vorlonsoft.android.rate.AppRate.showRateDialogIfMeetsConditions (AppRate.java:101)
....