【发布时间】:2021-08-11 17:19:48
【问题描述】:
使用 Android Studio 4.2.1,在我的 build.gradle 文件中将 sdk 目标更改为 Android 12 后,我收到 Manifest merger failed with multiple errors, see logs 错误。
Merged Manifest标签显示的错误如下:
Merging Errors:
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. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
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. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
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. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
但是android:exported 标签已经应用在我的 AndroidManifest.xml 文件中。我只有一项活动。没有服务或广播接收器。见下文:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mydomain.myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="com.mydomain.myapp.MyApplication"
android:allowBackup="false"
tools:replace="allowBackup"
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.mydomain.myapp.ui.MainActivity"
android:exported="true">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
我的 build.gradle(:app) 文件:
android {
compileSdkVersion("android-S")
buildToolsVersion "30.0.3"
defaultConfig {
...
minSdkVersion 23
targetSdkVersion("S")
...
}
知道如何解决这个问题吗?
【问题讨论】:
-
您确定“合并清单”选项卡中显示的清单不包含其他组件吗?图书馆可以贡献活动、服务和接收者。
-
@CommonsWare 这个问题似乎确实是由第三方库缺少
android:exported标签引起的。 Merged Manifest 选项卡显示为空(“Nothing to show”),因为合并失败,所以我不得不使用低于 Android 12 的目标进行重建以进行调查。谢谢! -
这很有趣,感觉就像 Studio 中的错误/限制。即使它不能提供普通合并清单选项卡的所有功能,它至少应该显示合并清单包含的内容,仅适用于像这样的场景。
-
@CommonsWare 同意。如果右侧面板中的错误可以指出是哪个组件导致了错误,那就太好了。为了增加混淆,在右侧面板的顶部,它显示:“其他清单文件(包含在合并中,但没有贡献任何元素)”我将其解释为“其他清单文件不是错误的来源.
-
@CommonsWare 项目所需但未通过指定
android:exported标志进行更新以针对 Android 12 进行测试的第三方库呢?我正在开发一个具有很多依赖项的大型框架,并希望针对 Android 12 进行测试。我知道一些库不会很快更新清单。我们是否应该查看失败的清单合并并明确覆盖所有尚未设置其exported标志的意图?
标签: android android-studio android-manifest android-12