android - 添加了 android:exported 但仍然出现错误 需要针对 Android 12 及更高版本的应用程序才能为 android:exported 指定显式值
问题描述
我已添加android:exported="true"
到清单中的唯一活动,但在将编译 sdk 和目标 sdk 版本更新为 31 后仍然出现错误。我还尝试重建项目,使缓存无效并重新启动,但这没有帮助
错误- 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.
AndroidManifest 文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xyz.abc">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".framework.presentation.BaseApplication"
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/AppTheme">
<activity android:name="com.xyz.presentation.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
合并清单错误
appcompat-resources:1.3.1 manifest, runtime-livedata:1.0.0 manifest, runtime-saveable:1.0.1 manifest, firebase-measurement-connector:19.0.0 manifest, vectordrawable-animated:1.1.0 manifest, main nav_graph。 xml 导航文件合并错误:错误:需要为 . 面向 Android 12 及更高版本的应用需要为
android:exported
当相应的组件定义了意图过滤器时。有关详细信息,请参阅 https://developer.android.com/guide/topics/manifest/activity-element#exported。Dairy.app 主清单(此文件)错误:需要为 . 面向 Android 12 及更高版本的应用需要为android:exported
相应组件定义了 Intent 过滤器时指定显式值。有关详细信息,请参阅 https://developer.android.com/guide/topics/manifest/activity-element#exported。Dairy.app 主清单(此文件)错误:需要为 . 面向 Android 12 及更高版本的应用需要为android:exported
当相应的组件定义了意图过滤器时。有关详细信息,请参阅 https://developer.android.com/guide/topics/manifest/activity-element#exported。Dairy.app 主清单(此文件)
解决方案
androidx.test:core
库版本 1.3.0。升级到 1.4.0 版解决了这个问题。
推荐阅读
- javascript - 如何在没有 jQuery 的情况下将所有 img src 替换为 data-src 以实现延迟加载
- keras - 2 个输出,具有 2 个不同的损失函数,但带有生成器
- rust - 将非复制变量移动到异步闭包中:捕获的变量无法逃脱 `FnMut` 闭包体
- python - 在应用程序中的两个模板之间导航时出现 Django 错误 404
- python - 为什么 Tukey 成对测试会导致 NaN?
- reactjs - 如何使用 AWS Cognito AmplifyAuthenticator 设置可选 MFA?
- python - python 上的 keras 和 tensorflow - ValueError: ('NumpyArrayIterator' 中的输入数据应该有 4 级。你传递了一个带有形状的数组', (36848,))
- java - Java中的连接(带int的字符串)值
- google-sheets - 我在不同批次的同一项目上得到了不同的成本价格 销售中批次成本价格的公式
- php - 如何使用 PHP 下载大文件