Open SimonCierniewski opened 1 month ago
+1, came here to report this as well
Nevermind, I figured it out. One of the services in my app subclasses DfuBaseService
, so I just added the foregroundServiceType
in the manifest for that service:
<service
android:name=".core.firmware.FirmwareUpdateService"
android:foregroundServiceType="connectedDevice" />
@SimonCierniewski
@roland-ryan-rm Your fix worked for me as well. Thank you!
However, it could also be fixed in library by adding foregroundServiceType
in startForeground(DfuBaseService.java:1926)
try {
startForeground(NOTIFICATION_ID, builder.build());
} catch (final SecurityException e) {
loge("Service cannot be started in foreground", e);
logi("Starting DFU service in background instead");
}
Where do you suspect the issue?
Issue in DFU library, e.g. upload stops in the middle
Version
2.5.0
Describe the issue
On Android SDK 34 I'm getting
android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{8bad461 13729:com.carrot.pivot/u0a406} targetSDK=34
becauseDfuBaseService
is missing requiredforegroundServiceType
. https://developer.android.com/about/versions/14/changes/fgs-types-required#include-fgs-type-runtimeRelevant log output
android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{8bad461 13729:com.carrot.pivot/u0a406} targetSDK=34 at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53) at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49) at android.os.Parcel.readParcelableInternal(Parcel.java:5016) at android.os.Parcel.readParcelable(Parcel.java:4998) at android.os.Parcel.createExceptionOrNull(Parcel.java:3178) at android.os.Parcel.createException(Parcel.java:3167) at android.os.Parcel.readException(Parcel.java:3150) at android.os.Parcel.readException(Parcel.java:3092) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6960) at android.app.Service.startForeground(Service.java:776) at no.nordicsemi.android.dfu.DfuBaseService.startForeground(DfuBaseService.java:1926) at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1153) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:77) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.os.HandlerThread.run(HandlerThread.java:85)