Coffee icon indicating copy to clipboard operation
Coffee copied to clipboard

App crash after update to 2.20

Open tuch96 opened this issue 1 year ago • 6 comments

After the update to 2.20 (f-droid version) the app crash when pressing the tile button.

Android 14 on Pixel 5.

Find enclosed the bug report:

type: crash
osVersion: google/redfin/redfin:14
package: com.github.muellerma.coffee:40
process: com.github.muellerma.coffee
processUptime: 52955 + 276 ms
installer: com.android.packageinstaller

android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.github.muellerma.coffee/.ForegroundService
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
	at android.os.Parcel.readParcelableInternal(Parcel.java:4890)
	at android.os.Parcel.readParcelable(Parcel.java:4872)
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3061)
	at android.os.Parcel.createException(Parcel.java:3050)
	at android.os.Parcel.readException(Parcel.java:3026)
	at android.os.Parcel.readException(Parcel.java:2968)
	at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:5999)
	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1952)
	at android.app.ContextImpl.startForegroundService(ContextImpl.java:1927)
	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:830)
	at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(Unknown Source:0)
	at androidx.core.content.ContextCompat.startForegroundService(Unknown Source:6)
	at com.github.muellerma.coffee.ForegroundService$Companion.changeState(Unknown Source:90)
	at com.github.muellerma.coffee.tiles.ToggleTile.onClick(Unknown Source:12)
	at android.service.quicksettings.TileService$H.handleMessage(TileService.java:494)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8199)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ExecInit.main(ExecInit.java:49)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)

tuch96 avatar Oct 27 '23 17:10 tuch96

Can confirm this is caused by the update for Android 14 in https://github.com/mueller-ma/Coffee/commit/4284c7f78a536e04d8dc1bc5bd818c1e55b4d1c4

When testing the upgrade, if the app is already opened the issue can't be reproduced, hence why it was not spotted. Targeting back to API 33 resolves the issue, although I'm curious on the change in the ForegroundService since the android 14 changelist just mentions the addition of the type, which was already added in https://github.com/mueller-ma/Coffee/commit/40722f1bf8db99b22547cfd81cdd890349a33bc6 (also the exception would be MissingForegroundServiceTypeException instead of ForegroundServiceStartNotAllowedException).

mvmike avatar Oct 28 '23 10:10 mvmike

After a bit of digging (the only difference with the documentation was to add ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC in the startForeground method, but it's still crashing) looks like it's a bug: issuetracker.google.com/issues/299506164.

Maybe the easiest path for now is to downgrade targetSdkVersion to 33

mvmike avatar Oct 28 '23 19:10 mvmike

I wasn't able to reproduce this bug, but reverted the targetSdk for now and released a new version: https://github.com/mueller-ma/Coffee/releases/tag/2.21

mueller-ma avatar Oct 29 '23 19:10 mueller-ma

Perfect. I'll let you know if it works as soon as the new version appears on f-droid.

tuch96 avatar Oct 29 '23 19:10 tuch96

Can confirm the issue is fixed in both the emulator and in my device with the 2.21 release 🙂

mvmike avatar Oct 29 '23 20:10 mvmike

The problem has been fixed with the new f-droid version 2.21. Thanks!!

tuch96 avatar Nov 03 '23 19:11 tuch96