Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 14: MissingForegroundServiceTypeException #1093

Closed
ignoramous opened this issue Oct 5, 2023 · 6 comments
Closed

Android 14: MissingForegroundServiceTypeException #1093

ignoramous opened this issue Oct 5, 2023 · 6 comments
Assignees
Labels
bug Something isn't working P0 Priority: 0 (urgent and important)

Comments

@ignoramous
Copy link
Collaborator

          I can no longer use this app after updating to Android 14.
10-04 17:32:53.426 18682 18682 E AndroidRuntime: android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{51c5a3e 18682:com.celzero.bravedns/u0a400} targetSDK=34
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Parcel.readParcelableInternal(Parcel.java:4870)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Parcel.readParcelable(Parcel.java:4852)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Parcel.createExceptionOrNull(Parcel.java:3052)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Parcel.createException(Parcel.java:3041)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Parcel.readException(Parcel.java:3024)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Parcel.readException(Parcel.java:2966)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.app.Service.startForeground(Service.java:775)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at com.celzero.bravedns.service.BraveVPNService$onStartCommand$1.invokeSuspend(BraveVPNService.kt:1206)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at com.celzero.bravedns.service.BraveVPNService$onStartCommand$1.invoke(Unknown Source:8)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at com.celzero.bravedns.service.BraveVPNService$onStartCommand$1.invoke(Unknown Source:2)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at com.celzero.bravedns.service.BraveVPNService$ui$1.invokeSuspend(BraveVPNService.kt:2186)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:958)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:205)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:294)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8177)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
10-04 17:32:53.426 18682 18682 E AndroidRuntime: 	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@d1d5641, Dispatchers.Main]

Originally posted by @Mygod in #962 (comment)

Ref: https://developer.android.com/about/versions/14/changes/fgs-types-required

@ignoramous ignoramous added bug Something isn't working P0 Priority: 0 (urgent and important) labels Oct 5, 2023
@ignoramous
Copy link
Collaborator Author

<manifest ...>
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <application ...>
      <service
          android:name="..."
+          android:foregroundServiceType="systemExempted"
          android:exported="...">
      </service>
    </application>
</manifest>

https://developer.android.com/about/versions/14/changes/fgs-types-required#system-exempted

@Mygod
Copy link
Contributor

Mygod commented Oct 5, 2023

Also needs permission FOREGROUND_SERVICE_SYSTEM_EXEMPTED.

@Mygod
Copy link
Contributor

Mygod commented Oct 19, 2023

I guess I'll downgrade to v0.5.5a then?

@ignoramous
Copy link
Collaborator Author

ignoramous commented Oct 19, 2023

guess I'll downgrade to v0.5.5a then?

You mean v055? Good bet. We have fixed an unbelievable number of bugs in v055b, but we are struggling to release it given the wave of refactor it has triggered. One of these it will be stable enough. It is close to a release unless we discover another terrible bug.

@hussainmohd-a
Copy link
Collaborator

Added foregroundServiceType for VpnService as SystemExempted. Added as part of v055d (live on GitHub and Website)

@ignoramous
Copy link
Collaborator Author

type: crash
osVersion: Redmi/sweet_eea/sweet:13/RKQ1.210614.002/V14.0.9.0.TKFEUXM:user/release-keys
package: com.celzero.bravedns:36
process: com.celzero.bravedns
processUptime: 384 + 50 ms
installer: com.celzero.bravedns

java.lang.IllegalArgumentException: foregroundServiceType 0x00000400 is not a subset of foregroundServiceType attribute 0x40000000 in service element of manifest file
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3074)
	at android.os.Parcel.createException(Parcel.java:3054)
	at android.os.Parcel.readException(Parcel.java:3030)
	at android.os.Parcel.readException(Parcel.java:2972)
	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6825)
	at android.app.Service.startForeground(Service.java:862)
	at com.celzero.bravedns.service.BraveVPNService$onStartCommand$1$$ExternalSyntheticApiModelOutline0.m(SourceFile:0)
	at com.celzero.bravedns.service.BraveVPNService$onStartCommand$1.invokeSuspend(Unknown Source:74)
	at com.celzero.bravedns.service.BraveVPNService$onStartCommand$1.invoke(SourceFile:0)
	at com.celzero.bravedns.service.BraveVPNService$onStartCommand$1.invoke(SourceFile:0)
	at com.celzero.bravedns.service.BraveVPNService$ui$1.invokeSuspend(Unknown Source:30)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:11)
	at kotlinx.coroutines.DispatchedTask.run(Unknown Source:98)
	at android.os.Handler.handleCallback(Handler.java:958)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8275)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@cde266, Dispatchers.Main]
Caused by: android.os.RemoteException: Remote stack trace:
	at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2064)
	at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1690)
	at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13397)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3418)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2782)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Priority: 0 (urgent and important)
Projects
None yet
Development

No branches or pull requests

3 participants