react-native-background-actions icon indicating copy to clipboard operation
react-native-background-actions copied to clipboard

Background service not starting on Android

Open apapalillo opened this issue 1 year ago • 3 comments

Hi everybody

I encountered an issue in the past days. After upgrading RN to 0.72 the background service wasn't starting anymore

After hours of debugging I figured out I needed to add an exclusion in the proguard file:

# React Native Background Actions
-keep public class com.asterinet.react.bgactions.** {*;}

Best regards!

apapalillo avatar Jan 23 '24 08:01 apapalillo

I think the service is not automatically added, so you'll need to add it in your AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
    ...
    <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" />
   ...
  </application>
</manifest>

pmdev71 avatar Jan 23 '24 11:01 pmdev71

I think the service is not automatically added, so you'll need to add it in your AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
    ...
    <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" />
   ...
  </application>
</manifest>

Hi pmdev71, thanks for your feedback. I also thought it could be a manifest issue, but I found out it was already correctly declared in there. Only the proguard rule fixed the issue for me.

apapalillo avatar Jan 23 '24 11:01 apapalillo

i have same problem, the message is

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':react-native-background-actions'.

Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

 android {
     namespace 'com.example.namespace'
 }

 If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

Ivandeclei avatar Feb 23 '24 14:02 Ivandeclei

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

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jun 17 '24 08:06 github-actions[bot]