android - 为什么当 targetSdkVersion 为 31 时,我收到“清单合并失败:...需要为 `android:exported` 指定显式值”?
问题描述
我试图在我的物理设备上运行一个 HelloWorld 项目,当我单击一个具有空活动的新项目时,Android Studio 创建该项目,但是当我运行该项目时,我收到 Manifest 合并失败,仅当 compileSdkVersion 为 31
build.gradle(Module) 包含:
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "com.example.helloworld"
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
因此,当我运行项目时,我收到此错误:
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.
问题是:为什么我在build.gradle(Module)中使用SdkVersion 29时没有出现这个错误,如下?
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.helloworld"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
最后,这让我产生了疑问。如果新项目是自动创建以使用最新的 SDK 版本编译的,android:exported
为什么它没有自动插入到 Manifest 中?
解决方案
推荐阅读
- python - 如何在 mac os 上将我的 python 项目共享到没有 python 的计算机?
- java - java中如何检查二维数组的两个房间之间是否存在某个元素
- html - 为什么我的输入没有占据我的 flexbox 容器的整个宽度
- swift - 如何从另一个视图控制器访问/传递变量?它不是下一个视图控制器,而是 Swift 中下一个视图控制器之后的视图控制器
- pandas - Pandas - 查找两个或更多满足条件的行
- javascript - 如何解决反应本机navigation.navigate 错误
- json - 在 Swift 中发送 json POST 请求在读取 json 时返回错误
- python - 未安装 Visual Studio 代码 Python
- python - 尝试执行特定的 python 脚本,但执行了另一个脚本
- javascript - 如何在“React Native Simple Store”中获取数组值?