App stops working on Android 7 (NoSuchMethodError)
Describe your problem!
An Android 7 user contacted us, that after activating the statubar icon option the app crashes. Afterwards the app can no longer be started.
It seems this function is not supported.
How to reproduce?
- Use Android 7 (emulator)
- Start WhereYouGo
- Activate settings - Appearance - StatusBar Icon
- Close WhereYouGo
- Open WhereYouGo again
Actual result after these steps?
App can no longer be started but crashes on startup
2022-01-19 21:14:51.206 8651-8651/menion.android.whereyougo E/UncaughtExceptionHandler: uncaughtException main
java.lang.Exception: java.lang.NoSuchMethodError: No direct method <init>(Landroid/content/Context;Ljava/lang/String;)V in class Landroid/app/Notification$Builder; or its super classes (declaration of 'android.app.Notification$Builder' appears in /system/framework/framework.jar)
at menion.android.whereyougo.utils.Logger.e(Logger.java:50)
at menion.android.whereyougo.utils.ExceptionHandler.uncaughtException(ExceptionHandler.java:27)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
2022-01-19 21:14:51.212 8651-8651/menion.android.whereyougo E/AndroidRuntime: FATAL EXCEPTION: main
Process: menion.android.whereyougo, PID: 8651
java.lang.NoSuchMethodError: No direct method <init>(Landroid/content/Context;Ljava/lang/String;)V in class Landroid/app/Notification$Builder; or its super classes (declaration of 'android.app.Notification$Builder' appears in /system/framework/framework.jar)
at menion.android.whereyougo.utils.NotificationService.startNotificationService(NotificationService.java:81)
at menion.android.whereyougo.utils.NotificationService.onStartCommand(NotificationService.java:55)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Expected result after these steps?
Normal operation
Reproducible
Yes
WhereYouGo Version
2022.01.10
System information
Android 7
Additional Information
Only mitigation is to "Clear data" of the app to startover in factory settings
Seems to happen below API26
Hi there just checked and there are some issues with the code in menion.android.whereyougo.utils.NotificationService. That class is using API 26+ features. I am not experienced enough in Android programming but it looks to me that at least this part of the code requires Android 8 and higher and some backport would be necessary, i guess. Kind of confusing as the gradle file indicates the project to be compatible to API 21.
Using NotificationCompat seems to fix this error, tested against API 23 (Android 6), see PR #418
Fixed with #418