gpt4 book ai didi

android - 针对 Android 12 的 list 合并失败

转载 作者:行者123 更新时间:2023-12-03 21:05:10 29 4
gpt4 key购买 nike

使用 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 文件中。我只有一项 Activity 。没有服务或广播接收器。见下文:

<?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")
...
}
知道如何解决这个问题吗?

最佳答案

该问题是由缺少 android:exported 的 3 个 Activity 引起的。 androidx.test:core 中的属性库版本 1.3.0 .升级到版本 1.4.0-beta01解决了这个问题。
如果您在针对 Android 12 后遇到错误,最简单的调试方法是:

  • 降级到之前的 sdk 版本
  • 重建项目
  • 构建成功后,打开项目的AndroidManifest.xml .
  • 在窗口底部,单击 Merged Manifest标签
  • 寻找任何<activity>其中包括 <intent-filter>标签并且缺少 android:exported属性

  • 如果您想确保这些 Activity 是问题所在,请将它们直接添加到您项目的 AndroidManifest.xml 中。缺少 android:exported 的文件添加属性并尝试重建项目。
    所以如果 <activity android:name="com.domain.ProblemActivity">缺少 android:exported属性,将其添加到您的 AndroidManifest.xml像这样的文件:
    <activity 
    android:name="com.domain.ProblemActivity"
    android:exported="true" >
    针对 Android 12 重新构建,如果它有效,那么你发现了这个错误!
    谢谢 @MikePenz为我指明了正确的方向。

    关于android - 针对 Android 12 的 list 合并失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67654506/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com