question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
Y-k-Ycommented, 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
2reactions
harshgupta-harrycommented, Sep 9, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Studio error: "Manifest merger failed: Apps targeting ...
Manifest merger failed: Apps targeting Android 12 and higher are required to specify an explicit value for android: exported when the ...
Read more >
Behavior changes: Apps targeting Android 12
Compile your app to target Android 12 (API level 31) by targetSdkVersion . ... are required \ to specify an explicit value for...
Read more >
Issues - GitHub
Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter ......
Read more >
Apps targeting Android 12 and higher are required to specify ...
How to solve Android Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the ...
Read more >
Let's use Android 12, Migration of our Android Apps to ...
Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found