清单合并失败:需要为 <activity>

问题描述 投票:0回答:2

我的清单文件有问题,错误消息:

Manifest合并失败:android:exported需要明确指定为.当相应组件定义了意图过滤器时,面向 Android 12 及更高版本的应用需要为

android: exported
指定显式值。有关详细信息,请参阅 https://developer.android.com/guide/topics/manifest/activity-element#exported。

我的 AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyTheme">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:exported="true"
            android:name=".Activities.SplashScreenActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
        </activity>
    </application>

</manifest>

这篇post描述了一个解决方案,但它不起作用或者我做错了一些事情。也许有人有类似的问题,请告诉我如何解决。

java android android-manifest
2个回答
15
投票
  1. 降级或升级到以前的 sdk 版本,然后重建项目。
  2. 打开您的项目的
    AndroidManifest.xml
  3. 单击“合并清单”选项卡[位于窗口底部]
  4. 找出包含
    <activity>
    标签的哪个
    <intent-filter>
    缺少
    android:exported
    属性
  5. 如果找到,则右键单击并按
    Go to Declaration
    然后将
    android:exported
    属性添加到活动标签
  6. 重建项目

希望它会起作用。它对我有用。


0
投票

与第一个答案相关,我可以在第 5 步中添加:

  1. 添加到
© www.soinside.com 2019 - 2024. All rights reserved.