Issue
I'm having this error on a Jetpack Compose project.
Manifest merger failed : android:exported needs to be explicitly specified for . 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
It all started when I added this dependency
implementation 'com.shakebugs:shake:14.4.0'
I followed the setup here https://www.shakebugs.com/docs/android/setup
Here is my Manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uticodes.compose_otp_input_field">
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Compose_otp_input_field">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Compose_otp_input_field.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest> ```
App class
```class App : Application() {
override fun onCreate() {
super.onCreate()
Shake.getReportConfiguration().isInvokeShakeOnShakeDeviceEvent = true
Shake.start(this, "clientId", "clientScret")
}
} ```
My compileSdk ```compileSdk 31 ``` , ```minSdk 21``` , ``` kotlinCompilerVersion '1.5.21'``` , ```compose_version = '1.0.1' ``` , ```gradle:7.0.1 ```
Solution
When you are targeting API level 31, all activities with intent-filters, services, receivers, providers must explicitly specify whether they are exported or not in AndroidManifest.xml
android:exported="true"
Also this issue can be happening because some of your dependencies (3rd party libs) do not have this attribute set. In order to fix that you should override exported
attribute for them:
<activity android:name="name_of_the_activity_inside_library">
android:exported="false|true"
tools:node="merge" />
You will be able to remove this once the libs your are using adds exported
attribute.
Note: the manifest merge task fails without generating the manifest when targeting Android 12 and you can't event find what causing the issue, so my advise is to compile the app using a targetSdk 30 and find which components have this issue in the generated manifest.
Answered By - asamoylenko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.