WhereYouGo icon indicating copy to clipboard operation
WhereYouGo copied to clipboard

App stops working on Android 7 (NoSuchMethodError)

Open Lineflyer opened this issue 4 years ago • 2 comments

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

Lineflyer avatar Jan 19 '22 20:01 Lineflyer

Seems to happen below API26

Lineflyer avatar Jan 19 '22 20:01 Lineflyer

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.

dawnstrider avatar Aug 19 '22 22:08 dawnstrider

Using NotificationCompat seems to fix this error, tested against API 23 (Android 6), see PR #418

moving-bits avatar Feb 18 '23 20:02 moving-bits

Fixed with #418

moving-bits avatar Feb 19 '23 17:02 moving-bits