美文网首页
编译报错:Manifest merge failed : Att

编译报错:Manifest merge failed : Att

作者: 北京朝阳区精神病院院长 | 来源:发表于2022-06-29 18:16 被阅读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> 元素中。

    • 根据As给出的提示加上tools:replace 属性,编译一下,还是报错。

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

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

    • 加上android:appComponentFactory属性,可以正常编译不报错了。但appComponentFactory属性需要\color{red}{注意}

      编译好的apk用模拟器(逍遥安卓版本 7.0)测试,可以安装能正常进入游戏,各项sdk均正常。但是在安卓11的设备adb install 时候出问题了。 Installation did not succeed.The application could not be installed: INSTALL_FAILED_USER_RESTRICTED

      表现的现象:编译apk 没问题,无法安装到设备上。 通过qq直接安装到手机,显示解析软件包时出现问题。

      观察logcat 日志 抓到的有效日志(at Binary XML file line #35): Empty class name in package xxx,定位到appComponentFactory属性没有指定 具体的字符(android:appComponentFactory=" " )

      修改后android:appComponentFactory="111"加上了任意字符后,经测试安装正常。

    完整解决方案

    \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>
    

    相关文章

      网友评论

          本文标题:编译报错:Manifest merge failed : Att

          本文链接:https://www.haomeiwen.com/subject/ettxbrtx.html