Rapsssito / react-native-background-actions

React Native background service library for running background tasks forever in Android & iOS.
MIT License
819 stars 117 forks source link

Not working with Android 14 #219

Closed fridayowl closed 5 months ago

fridayowl commented 7 months ago

can't get this package to work on Android 14. It's causing the app to crash

soyma20 commented 7 months ago

Same here. I've connected the package as the readme says, but it's crashing the app without an error message

nikhilmishra83 commented 7 months ago

same with android 13.

fridayowl commented 7 months ago

same with android 13.

It works well with andorid 13 .

SERCHAT commented 7 months ago

Same with android 14 app crashing after start background service

marcelxsilva commented 7 months ago

Maybe it could be this: https://github.com/Rapsssito/react-native-background-actions?tab=readme-ov-file#warning

it worked for me, downgrading the targetSdkVersion version to 33, not good, but I'm looking for another solution.

rajkumarthirumalai commented 7 months ago

when i try to start the background action,App keep crashing without errors so i tired adb logcat

and got the below error in it ,May be it might help to resolve

Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.

faizanbutt commented 6 months ago

@rajkumarthirumalai I updated FLAG_MUTABLE to FLAG_IMMUTABLE but after that I am getting this error: java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@7a9878a with Intent { cmp=com.myapp/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{5a92e72 15113:com.myapp/u0a195} 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

Did you also faced the same ? Or how did you solve the previous one ?

rajkumarthirumalai commented 6 months ago

@rajkumarthirumalai I updated FLAG_MUTABLE to FLAG_IMMUTABLE but after that I am getting this error: java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@7a9878a with Intent { cmp=com.myapp/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{5a92e72 15113:com.myapp/u0a195} 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

Did you also faced the same ? Or how did you solve the previous one ?

i made the changes what said here https://github.com/Rapsssito/react-native-background-actions/issues/200

https://github.com/Rapsssito/react-native-background-actions/issues/200#issuecomment-1896226130

akinlekan28 commented 6 months ago

@rajkumarthirumalai I updated FLAG_MUTABLE to FLAG_IMMUTABLE but after that I am getting this error: java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@7a9878a with Intent { cmp=com.myapp/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{5a92e72 15113:com.myapp/u0a195} 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

Did you also faced the same ? Or how did you solve the previous one ?

You're missing <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" /> permission strings. Also make sure your app has the appropriate permissions granted before starting the foreground service.

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 4.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Yashi1919 commented 2 months ago

Did any one here got a solution for this issue

this is my manifest file please help me

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.wallodynamo">

<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<!-- Foreground Service Permissions -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" tools:targetApi="m" />

<!-- Location Permissions -->
<!-- ACCESS_FINE_LOCATION allows fine (GPS) location access -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- ACCESS_BACKGROUND_LOCATION should be requested only if your app truly requires background location access -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
    tools:targetApi="r" />

<!-- Storage Permissions - Use Scoped Storage instead of broad permissions -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:targetApi="30"/>

<application
    android:name=".MainApplication"
    android:label="@string/app_name"
    android:icon="@mipmap/wallo"
    android:roundIcon="@mipmap/wallo"
    android:allowBackup="false"
    android:theme="@style/AppTheme"
    android:supportsRtl="true">

    <!-- Main Activity -->
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter android:label="filter_react_native">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="wallodynamo" />
        </intent-filter>
    </activity>

    <!-- Foreground Service Declaration -->
    <service
        android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask"
        android:exported="false"
        android:foregroundServiceType="location|mediaPlayback|dataSync"
        android:permission="android.permission.BIND_JOB_SERVICE"
        tools:replace="android:foregroundServiceType">
    </service>

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