java - Android Studio 错误 : "Manifest merger failed: Apps targeting Android 12"

标签 java android android-studio android-emulator runtime-error

我已将我的模拟器版本和 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.


我该如何解决?
这是一个屏幕截图:
This is a screenshot.
使用 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/

相关文章:

java - 如何读取 Java 中序列化对象的大小(以字节为单位)?

android - 使用publishToMavenLocal创建远程Maven存储库的本地副本

android-studio - 有什么方法可以使用 Android Studio 中的设备文件资源管理器检查 flutter 中的 Sqflite 数据库表吗?

android - 如何将现有项目从另一个文件夹导入到 Android studio 中的工作区

java - 使用 JACKSON 解析 python 字典

java - 为什么我的 LinkedList 充满了相同的对象?

java - 多个 Spring Boot 应用程序,只想运行一个

android - 如何在android中存储图像?

android - 适用于 Android 的 SAXParser 工作示例

Android Studio 未检测到 Microsoft Android 模拟器