mjaakko / NeoStumbler

New stumbler application for contributing data to geolocation services
MIT License
129 stars 12 forks source link

Crash when uploading on Android 11 #72

Closed HorayNarea closed 6 months ago

HorayNarea commented 6 months ago

Logcat after pushing the Upload Button:

--------- beginning of crash
05-16 21:21:19.988 22862 22910 E AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
05-16 21:21:19.988 22862 22910 E AndroidRuntime: Process: xyz.malkki.neostumbler, PID: 22862
05-16 21:21:19.988 22862 22910 E AndroidRuntime: java.lang.IllegalStateException: Not implemented
05-16 21:21:19.988 22862 22910 E AndroidRuntime:    at androidx.work.CoroutineWorker.g(Unknown Source:4)
05-16 21:21:19.988 22862 22910 E AndroidRuntime:    at G1.e.q(Unknown Source:34)
05-16 21:21:19.988 22862 22910 E AndroidRuntime:    at q3.a.o(Unknown Source:7)
05-16 21:21:19.988 22862 22910 E AndroidRuntime:    at G3.M.run(Unknown Source:114)
05-16 21:21:19.988 22862 22910 E AndroidRuntime:    at M3.a.run(Unknown Source:95)
05-16 21:21:19.988 22862 22910 E AndroidRuntime:    Suppressed: L3.g: [v0{Cancelling}@8662ab2, Dispatchers.Default]
05-16 21:21:19.997 22862 22910 D OOMEventManagerFK: checkEventAndDumpForJE: 0
05-16 21:21:20.067 22862 22910 I Process : Sending signal. PID: 22862 SIG: 9

As far as I can tell this happens because .setExpedited() is used in

https://github.com/mjaakko/NeoStumbler/blob/594221533d38f6a1a87369a1abff8a768dd228b1/app/src/main/java/xyz/malkki/neostumbler/ui/composables/ReportUploadButton.kt#L77 https://github.com/mjaakko/NeoStumbler/blob/594221533d38f6a1a87369a1abff8a768dd228b1/app/src/main/java/xyz/malkki/neostumbler/ui/composables/ReportReuploadButton.kt#L108

but ReportSendWorker does not override getForegroundInfo() , so it throws a NotImplementedException … but only on Android 11 or older, as per: https://developer.android.com/jetpack/androidx/releases/work#2.7.0

When using setExpedited(...), WorkManager delegates to expedited jobs in JobScheduler starting Android 12, while providing backwards compatibility on prior versions of Android by delegating to a Foreground Service.


I'm not sure if https://github.com/mjaakko/NeoStumbler/blob/594221533d38f6a1a87369a1abff8a768dd228b1/app/src/main/java/xyz/malkki/neostumbler/ui/composables/ExportDataButton.kt#L100 is also problematic - because you already override getForegroundInfo() on DataExportWorker I think that should be fine?


To be honest: I have no idea I'm doing & what all this means and have basically zero experience with Android/Java/Kotlin :D

mjaakko commented 6 months ago

Thanks for the bug report and analysis – seems that you're correct about the crash reason. I'll investigate and fix this