gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:04:02 25 4
gpt4 key购买 nike

我已将我的模拟器版本和 Android SDK 版本更新为 Android S (Android 12)。更新后,我无法运行该项目。我无法运行 Hello, World!项目(空项目),但我可以构建 Gradle,但我无法运行该项目。我总是得到错误:

Manifest merger failed: Apps targeting Android 12 and higher arerequired to specify an explicit value for android: exported when thecorresponding component has an intent filter defined. Seehttps://developer.android.com/guide/topics/manifest/activity-element#exportedfor 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, orbroadcast receivers that use intent filters, you must explicitlydeclare the android: exported attribute for these app components.


Warning: If an activity, service, or broadcast receiver uses intentfilters and doesn't have an explicitly-declared value forandroid:exported, your app can't be installed on a device that runsAndroid 12.


还有 check何时对“android:exported”值使用真/假。

关于java - Android Studio 错误 : "Manifest merger failed: Apps targeting Android 12",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67412084/

25 4 0
文章推荐: python-3.x - 调试 Numpy VisibleDeprecationWarning(来自不规则嵌套序列的 ndarray)
文章推荐: sql-server - 域\用户的 GRANT 语法
文章推荐: flutter - 如何在 Flutter 中将 List 保存到 SharedPreferences?