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

SDK 31 - Android 12 specify an explicit value for android:exported #571

Open
romancxx opened this issue Jul 11, 2022 · 14 comments
Open

SDK 31 - Android 12 specify an explicit value for android:exported #571

romancxx opened this issue Jul 11, 2022 · 14 comments

Comments

@romancxx
Copy link

Your Environment

  • Plugin version: 0.6.3
  • Platform: Android
  • OS version: 12
  • Device manufacturer and model: Mi 10 Lite
  • Running in Simulator: No
  • React Native version: 0.68.2
  • Plugin configuration options: /
  • Link to your project: /

Context

I am trying to run my app on Android after installing the package. I had a few errors that I solved with answers of other issues but I'm stuck with this one :

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/romancirier/Documents/freelance/SkydingApp/node_modules/@mauron85/react-native-background-geolocation/android/lib/src/main/AndroidManifest.xml Error:
	android:exported needs to be explicitly specified for <service>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@mauron85_react-native-background-geolocation:processDebugManifest'.
> A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
   > Manifest merger failed : android:exported needs to be explicitly specified for <service>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Not like the example app, I'm trying to compile with the SDK 31. I couldn't find any example using higher than 28 but it is mandatory for me. My build.gradle ext looks like :

    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        // I added this but it doesn't change anything with or without it
        googlePlayServicesVersion = "9.8.0"
        

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }

    }

My dependencies are (I'm using react-native-maps if that could be a problem) :

"@mauron85/react-native-background-geolocation": "^0.6.3",
    "@react-native-async-storage/async-storage": "^1.17.6",
    "@react-native-community/checkbox": "^0.5.12",
    "@react-navigation/bottom-tabs": "^6.3.1",
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.2",
    "@reduxjs/toolkit": "^1.8.1",
    "@sentry/react-native": "^3.4.3",
    "axios": "^0.27.2",
    "i18n-js": "^3.9.2",
    "moment": "^2.29.3",
    "react": "17.0.2",
    "react-native": "0.68.2",
    "react-native-animated-scroll-modal": "^0.6.5",
    "react-native-background-actions": "^2.6.7",
    "react-native-fast-image": "^8.5.11",
    "react-native-geolocation-service": "^5.3.0-beta.4",
    "react-native-gesture-handler": "^2.4.2",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-maps": "^0.30.1",
    "react-native-maps-directions": "^1.8.0",
    "react-native-pager-view": "^5.4.23",
    "react-native-permissions": "^3.3.1",
    "react-native-reanimated": "^2.8.0",
    "react-native-safe-area-context": "^4.2.5",
    "react-native-screens": "^3.13.1",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^12.3.0",
    "react-native-tab-view": "^3.1.1",
    "react-native-toast-message": "^2.1.5",
    "react-native-track-player": "^2.2.0-rc3",
    "react-redux": "^8.0.2",
    "redux-persist": "^6.0.0",
    "use-debounce": "^8.0.1"

I also added :

include ':@mauron85_react-native-background-geolocation-common'
project(':@mauron85_react-native-background-geolocation-common').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/common')
include ':@mauron85_react-native-background-geolocation'
project(':@mauron85_react-native-background-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/lib')

to the setting.gradle to solve another issue.

Expected Behavior

Build successfully

Actual Behavior

Error

Possible Fix

No idea.

Steps to Reproduce

  1. Installing the dependencies as I have
  2. Building the app

Context

Debug logs

@romancxx
Copy link
Author

If anyone is experiencing the same problem, I solved it by patching this package with :

       <service
            android:name="com.marianhello.bgloc.sync.AuthenticatorService">
            android:exported="true">  <<<<< Add this to AndroidManifest.xml L34

@gomezmark
Copy link

android:exported="true"

I tried this one, unlucky for me not working on my end.

Do you have any suggestion?

@skvaghasiya402
Copy link

skvaghasiya402 commented Nov 1, 2022

I solved it by

  • Deleting node_modules is as simple as writing the node_modules without a slash:
  • rm -rf node_modules // in your project path
  • npm install or npm install --force
  • npx react-native run-android

OR

add android:exported="true" in /node_modules/@mauron85/react-native-background-geolocation/android/lib/src/main/AndroidManifest.xml

I hope it's working.

@kapilavaiya
Copy link

android sdk 31, android exported fix #574

This

you have to add android:exported="true" in /node_modules/@mauron85/react-native-background-geolocation/android/lib/src/main/AndroidManifest.xml

I have tried this but still i'm getting this error

  • What went wrong:
    Execution failed for task ':@mauron85_react-native-background-geolocation:processDebugManifest'.

A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

@Y-k-Y
Copy link

Y-k-Y commented Nov 28, 2022

If anyone is experiencing the same problem, I solved it by patching this package with :

       <service
            android:name="com.marianhello.bgloc.sync.AuthenticatorService" // maybe should remove '>'
            android:exported="true">  <<<<< Add this to AndroidManifest.xml L34

@kapilavaiya
Copy link

<service
android:name="com.marianhello.bgloc.sync.AuthenticatorService" // maybe should remove '>'
android:exported="true"> <<<<< Add this to AndroidManifest.xml L34

Solved using this thanks !

@fatinfarzanaazizan
Copy link

hi, is there a way we can get this in the library and not update the AndroidManifest.xml manually?

@kapilavaiya
Copy link

kapilavaiya commented Feb 13, 2023

@fatinfarzanaazizan You can update your react native version if you don't want to update manually

@fatinfarzanaazizan
Copy link

@avaiyakapil thanks. can you help to explain how would that help? would it also help solving Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE error that occurs in DistanceFilterLocationProvider file for this library?

@adewalebanjo
Copy link

@fatinfarzanaazizan Did you find a solution to the Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE error?

@fatinfarzanaazizan
Copy link

@adewalebanjo no, still having this issue unfortunately.

@nassimmiled
Copy link

@fatinfarzanaazizan the same issue for me

@Linuhusainnk
Copy link

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE

Any solution?

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

10 participants