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

App crashing on android 14 #241

Open
divyaAtDelta opened this issue Sep 21, 2024 · 8 comments
Open

App crashing on android 14 #241

divyaAtDelta opened this issue Sep 21, 2024 · 8 comments

Comments

@divyaAtDelta
Copy link

I am performing background task to send users location to server after every 3 min. At the starting of the application i am asking for background location permission and while starting background service I am checking whether the permission has been given already or not?. If its given then only I am starting the background service. But, while starting permission was granted, but, now user put my application in the background and through settings app revoking the location permission. In this scenario application is crashing on android 14. But, on android 12 its working totally fine. Here I am sharing the crash report below,
Fatal Exception: java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@59c59be with Intent { cmp=com.delta.the.runner/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) mCallingUid=10544 }: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{a224dfd 27293:com.delta.the.runner/u0a544} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5134)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2481)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:257)
at android.os.Looper.loop(Looper.java:368)
at android.app.ActivityThread.main(ActivityThread.java:8839)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

Any help regarding this issue is highly appreciated.

@glrahulborah
Copy link

Facing the same issue

@Yashi1919
Copy link

Can you tell me how we can get the crash report

@glrahulborah
Copy link

@divyaAtDelta The issue is related to prerequisite permissions required to start the foreground service. In your case, you have used "location" type and as per the Android documentation it requires at least one permission. Just check runtime prerequisites for location type.

@divyaAtDelta
Copy link
Author

Can you tell me how we can get the crash report

I have got this from firebase console, as crashlytics is integrated in my project.

@divyaAtDelta
Copy link
Author

divyaAtDelta commented Sep 24, 2024

@divyaAtDelta The issue is related to prerequisite permissions required to start the foreground service. In your case, you have used "location" type and as per the Android documentation it requires at least one permission. Just check runtime prerequisites for location type.

what permission you were missing previously, and now by adding that permission has fixed your issue, because in my case, the mentioned permission are already there in my manifest file.

@glrahulborah
Copy link

@divyaAtDelta The issue is related to prerequisite permissions required to start the foreground service. In your case, you have used "location" type and as per the Android documentation it requires at least one permission. Just check runtime prerequisites for location type.

what permission you were missing previously, and now by adding that permission has fixed your issue, because in my case, the mentioned permission are already there in my manifest file.

Permission in manifest is required and you need to grant the location permission to the app before starting the background action.

@DiguinhoLNS
Copy link

DiguinhoLNS commented Oct 17, 2024

I try one solution and works well for now

on AndroidManifest.xml, add service for the backgroun service:

<service 
    android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" 
    android:foregroundServiceType="shortService"/>

on android/build.gradlew, update to sdk 34:

buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34

@DevAsrar
Copy link

DevAsrar commented Dec 5, 2024

Any update still same issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants