简体   繁体   中英

Manifest merger failed : android:exported needs to be explicitly specified for element <service#com.marianhello.bgloc.sync.AuthenticatorService>

I am trying to generate a signed build but getting this error in android studio Manifest merger failed: android:exported needs to be explicitly specified for element <service#com.marianhello.bgloc.sync.AuthenticatorService>. Apps targeting Android 12 and higher are required to specify an explicit value for Manifest merger failed: android:exported needs to be explicitly specified for element <service#com.marianhello.bgloc.sync.AuthenticatorService>. 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. when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. I really tried but was not able to resolve this issue, Could someone please help me how to resolve this issue? I am stuck and trying since 4 days, I would really appreciate your help guys. Thanks

Android Target SDK: 31

AndroidManifest.xml

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

  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
  <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
  <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <uses-library android:name="org.apache.http.legacy" android:required="false"/>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        tools:node="merge"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:exported="true"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <meta-data
     android:name="com.google.android.geo.API_KEY"
     android:value="AIzaSyAqSC9FdXG8r-JAKJS4883jdsd9"/>
     <!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
      <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                  android:value="true"/>
      <!-- Change the resource name to your App's accent color - or any other color you want -->
      <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                  android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
        </intent-filter>
    </receiver>

    <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false" >
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>
    </application>
</manifest>

Build gradle

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        ndkVersion = "21.4.7075529"
        playServicesVersion = "17.0.0"
        androidMapsUtilsVersion = "2.3.0"
        googlePlayServicesVersion = "+" // default: "+"
        firebaseMessagingVersion = "21.1.0" // default: "21.1.0"
        androidXCore = "1.7.0"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.1.3")
        classpath 'com.google.gms:google-services:4.3.10'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

Method 1. Reduce the Android API to a version below 31. Android 12 requires android:exported to be explicitly defined.

Method 2. If there is a problem in the dependency library, it is recommended to upgrade to the latest dependency. If the latest dependency has not solved this problem, you can directly click to the AndroidManifest.xml where the error is reported, directly edit the manifest file, and manually add the android:exported attribute. After the addition is complete, rebuild the project.

NOTE: The second method of editing AndroidManifest.xml is just a special way to get your project running. This modification is required every time the project is restarted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM