Android Studio Error Manifest merger failed : Apps targeting Android 12 exported already exists

116 views Asked by At

I'm not good at English, so I use a translator. I'm sorry.

I'm working on a project to control drones on mobile, and I'm going to find a module called dronekit and use it, but when I apply it, the same error appears.

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

my manifest:

    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

my build.gradle(:app):

android {
...
compileSdk 31
defaultConfig {
    ...
    minSdk 23
    targetSdk 31
    ...
}
dependencies {
...
implementation files('../libs/dronekit-android.3.0.2.aar')
}

As you can see, android:exported is already in it. But there's an error in "Merged Manifest". Please help me.

1

There are 1 answers

0
Aditya On

When you open the Android Library file(dronekit.aar) with WinRAR, you will see an AndroidManifest.xml file, open it with notepad or any text Editor and add a function

android:exported="true"

in every service and activity which are there. Then export it again in android studio and add dependency in build. gradle. It will work.