清单合并失败:针对 Android 12 的应用程序 - Android Studio 错误 [英] Manifest merger failed : Apps targeting Android 12 - Android Studio Error

查看:551
本文介绍了清单合并失败:针对 Android 12 的应用程序 - Android Studio 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将模拟器版本和 Android SDK 版本更新为 Android S (Android 12).更新后,我无法运行该项目.我无法运行 hello world 项目(空项目),但我可以构建成绩,但无法运行该项目.我总是收到错误:

<块引用>

清单合并失败:针对 Android 12 及更高版本的应用程序是需要为 android:exported 指定一个显式值,当相应的组件定义了一个意图过滤器.看

那么问题是在使用android 12 SDK时如何解决这个问题?问题 是关于将解决方案应用于此后的问题,此问题不同比重复提到的问题,这个问题比这个>

解决方案

您需要指定 android:exported="false"android:exported="true"代码>

清单:

<意图过滤器><action android:name="android.intent.action.MAIN";/><category android:name="android.intent.category.LAUNCHER";/></意图过滤器></活动>

文档<块引用>

如果您的应用面向 Android 12 并且包含活动、服务或使用意图过滤器的广播接收器,您必须明确为这些应用组件声明 android: 导出属性.

<块引用>

警告:如果活动、服务或广播接收器使用意图过滤器并且没有明确声明的值android:exported,你的应用无法安装在运行的设备上安卓 12.

另外检查何时对'使用真/假android:exported' 值

I hava updated my emulator version and Android SDK version to Android S (Android 12). After the update, I cannot run the project. I cannot run a hello world project (empty project), but I can build Grades as well as but can not run the project. I always got the error :

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.

Please anyone can help me?

Here is a screenshot:

So the question is how to solve this issue when using android 12 SDK? question is about the issue after applying the solution to this, This question is different than the question mentioned with the duplicate also this question is oldest than this

解决方案

You need to specify android:exported="false" or android:exported="true"

Manifest:

<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>

as mentioned in 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.

Also check when to use true/false for 'android:exported' value

这篇关于清单合并失败:针对 Android 12 的应用程序 - Android Studio 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆