【问题标题】:Apps targeting Android 12 and higher are required to specify an explicit value for 'android:exported' but I have such value面向 Android 12 及更高版本的应用需要为 'android:exported' 指定显式值,但我有这样的值
【发布时间】:2021-09-25 19:33:30
【问题描述】:

当我尝试编译 APK 文件时,我收到下一个错误: dove\frontend\android\src\main\AndroidManifest.xml Error: 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.

我有这样的价值,但 AGP 没有看到。我的价值清单:

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

    <application
            android:name=".DoveApplication"
            android:allowBackup="true"
            android:fullBackupContent="true"
            android:icon="@mipmap/ic_launcher"
            android:label="Dove"
            android:supportsRtl="true"
            android:theme="@style/Theme.Dove">
        <activity
                android:exported="true"
                android:name=".AppActivity"
                android:label="Dove"
                android:theme="@style/Theme.Dove.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

AGP 版本:4.2.2 除了降级targetSdk之外的任何解决方法?

【问题讨论】:

  • 检查您的合并清单,例如通过 Android Studio 清单编辑器中的“合并清单”选项卡。也许您正在使用的第三方库正在贡献一个缺少此属性的组件。
  • @CommonsWare 我只使用 compose 和 androidx.lifecycle:lifecycle-viewmodel-ktx。但我会检查谢谢。
  • @CommonsWare 有没有办法在 Intellij Idea 中检查它?因为我无法在 AS 中构建项目(出现“未知错误”)
  • 在 IDEA 的清单编辑器中似乎有一个“Merged Manifest”子选项卡(在 2021.2.2 版本上测试)。
  • @CommonsWare 我发现androidx.test.core 没有这样的价值,但我该怎么处理它?我没有将它添加到依赖项中

标签: android kotlin gradle android-gradle-plugin


【解决方案1】:

您需要做的就是打开清单并在底部面板中选择“Merged Manifest”,然后查找添加没有此属性的活动的依赖项。 在我的例子中,它是来自撰写单元测试的androidx.core.test

【讨论】:

    【解决方案2】:

    很可能是因为 react-native 版本。我在 react-native 0.63.4 上遇到了同样的问题,但在 react-native 0.66.4

    上没有错误

    【讨论】:

      猜你喜欢
      • 2022-01-06
      • 2021-10-11
      • 2021-10-03
      • 2023-02-12
      • 2022-06-11
      • 2022-01-21
      • 2023-01-15
      • 2021-11-16
      • 1970-01-01
      相关资源
      最近更新 更多