我已将我的模拟器版本和 Android SDK 版本更新为 Android S (Android 12)。更新后,我无法运行该项目。我无法运行 Hello, World!项目(空项目),但我可以构建 Gradle,但我无法运行该项目。我总是得到错误:
Manifest merger failed: 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.
我该如何解决?
这是一个屏幕截图:
使用 Android 12 SDK 时如何解决此问题?
This question是关于将解决方案应用于此问题后的问题,并且与此问题不同。此外,这个问题早于 this .
最佳答案
您需要指定 android:exported="false"
或 android:exported="true"
显现:
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.MyApplication.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
如 the document 中所述:If your app targets Android 12 and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android: exported attribute for these app components.
Warning: If an activity, service, or broadcast receiver uses intent filters and doesn't have an explicitly-declared value for android:exported, your app can't be installed on a device that runs Android 12.
还有check何时对“android:exported”值使用真/假。
关于java - Android Studio 错误 : "Manifest merger failed: Apps targeting Android 12",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67412084/