编译报错:Manifest merge failed : Att

2022-06-29  本文已影响0人  北京朝阳区精神病院院长

简述

接入sdk的过程中,遇到点坑。能看到此博文说明你也遇到了和我一样的问题,我做个记录,方便有缘人观看。不想看过程的同学,可以直接跳到底下直接看解决方案。

gradle 编译报错

Android Studio 游戏工程目前是非安卓X ,渠道给出了安卓X和非安卓X SDK 两种接入方案,我采用了非安卓X 接入方案。按文档中描述依赖各种jar或者aar。编译工程如无意外,果然还是出意外了,gradle编译报错。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
     //游戏 java层 有v7包的引用
    implementation 'com.android.support:appcompat-v7:28.0.0'
}
依赖的资源.png

\color{red}{编译报错信息如下}

Execution failed for task ':app:processReleaseManifest'.

Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [core-1.1.0.aar] AndroidManifest.xml:24:18-86

is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).

Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:9:5-96:19 to override.

依赖冲突.png

\color{blue}{翻译过来}

执行任务,合并资源失败:[ core-1.1.0.aar ] 清单文件中的属性 <application > android:appComponentFactory="androidx.core.app.CoreComponentFactory"/> 和[com.android.support:support-compat:28.0.0] 清单文件里面的属性冲突了。

\color{red}{注:}support-compat:28.0.0来自 implementation 'com.android.support:appcompat-v7:28.0.0'的gradle依赖。

\color{red}{建议:}将 ' tools:replace="android:appComponentFactory"'属性, 添加到清单文件中的 <application> 元素中。

\color{red}{错误信息:}tools:replace specified at line:9 for attribute android:appComponentFactory, but no new value specified

\color{red}{翻译过来:} 没有指定 android:appComponentFactory

完整解决方案

\color{red}{划重点:}android:appComponentFactory="任意字符"

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    
    <application
           android:appComponentFactory="111"
            tools:replace="android:appComponentFactory">
    </application>
    
</manifest>
上一篇下一篇

猜你喜欢

热点阅读