MovnaTeam / movna

Open-source training application.
GNU General Public License v3.0
0 stars 1 forks source link

App crashes when location on in release mode #36

Closed ronw98 closed 11 months ago

ronw98 commented 12 months ago

Reproduction steps:

System logs

E/AndroidRuntime(24405): FATAL EXCEPTION: main
E/AndroidRuntime(24405): Process: dev.movna.app.dev, PID: 24405
E/AndroidRuntime(24405): android.app.RemoteServiceException$BadForegroundServiceNotificationException: Bad notification(tag=null, id=75415) posted from package dev.movna.app.dev, crashing app(uid=10163, pid=24405): Couldn't create icon StatusBarIcon(icon=Icon(typ=RESOURCE pkg=dev.movna.app.dev id=0x7f040019) visible user=0 )
E/AndroidRuntime(24405):    at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1986)
E/AndroidRuntime(24405):    at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
E/AndroidRuntime(24405):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2242)
E/AndroidRuntime(24405):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(24405):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(24405):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(24405):    at android.app.ActivityThread.main(ActivityThread.java:7898)
E/AndroidRuntime(24405):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(24405):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(24405):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
ronw98 commented 12 months ago

Turns out the problem came from android resource shrinking: In release mode compilation removes unused resources from the final apk to avoid the app taking up unnecessary space. As the notification icon was only referenced in flutter code and not in android files it was removed by the compiler.

I added the keep.xml file that prevents the file from being removed.

The file was created following https://developer.android.com/build/shrink-code#keep-resources