Unfortunately this bug seems to keep reappearing😄 The clean install of 5.1.4 works perfectly fine (also thanks for crediting me in the release notes) but when updating from 4.0.1 with an existing save file it crashes again.
However this time its reproducible in the Emulator, so maybe that helps in getting rid of the bug.
Steps to reproduce:
- Check out the revision of the repository where version was updated to 4.0.1
- Build and clean install this version on the emulator
- Open the app and create an entry
- Check out the current master branch (5.1.4) and update the app on the emulator by building and running again
I appended the full crash log at the end, but the only relevant lines are
Caused by: java.io.InvalidClassException: com.katiearose.sobriety.Addiction;
at com.katiearose.sobriety.CacheHandler.readCache(CacheHandler.kt:17)
at com.katiearose.sobriety.Main.onCreate(Main.kt:61)
I don't really get why it crashes, because there is try catch blocks everywhere that should have caught that exception.
Mabye its worth considering to use a different way of storage, since these FileOutPutStreams etc. are a bit tricky to debug. Since the data is very simple, you could use Android's Shared Preferences, and save the list as a serialized string in a single key value pair there. Or if you want to debug the current system, here is the full crash log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.katiearose.sobriety, PID: 21703
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.katiearose.sobriety/com.katiearose.sobriety.Main}: java.io.InvalidClassException: com.katiearose.sobriety.Addiction; local class incompatible: stream classdesc serialVersionUID = -8477717136644775154, local class serialVersionUID = 7971970991809636397
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3635)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
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:2210)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.io.InvalidClassException: com.katiearose.sobriety.Addiction; local class incompatible: stream classdesc serialVersionUID = -8477717136644775154, local class serialVersionUID = 7971970991809636397
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:624)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1594)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1872)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1412)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427)
at java.util.ArrayList.readObject(ArrayList.java:791)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1066)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2013)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1899)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1412)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427)
at com.katiearose.sobriety.CacheHandler.readCache(CacheHandler.kt:17)
at com.katiearose.sobriety.Main.onCreate(Main.kt:61)
at android.app.Activity.performCreate(Activity.java:8051)
at android.app.Activity.performCreate(Activity.java:8031)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
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:2210)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
bug