Manifest merger failed : android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`
将targetsdk升级到34后报错
```
Execution failed for task ':app:processHuaweiDebugMainManifest'.
> Manifest merger failed : android:exported needs to be explicitly specified for <activity>. 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.
```
根据错误提示,targetSdkVersion大于等于SDK 31(也就是Android 12)时,如果有的Activity配置了Intent-filter,必须也同时配置exported属性,否则编译失败。
有2种解决方案
方案1:降低targetSdkVersion为30
根据现在的要求,targetSdkVersion 必须>=30,该方案不推荐。
方案2:将Manifest中有配置Intent-filter的Activity加上android:exported属性
例如:
```
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="standard"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
```
我的笔记