美文网首页
集成引入第三方library时出现错误Manifest merg

集成引入第三方library时出现错误Manifest merg

作者: OriginMonkey | 来源:发表于2019-03-21 15:24 被阅读0次

    @TOC

    集成引入第三方library时出现错误Manifest merger failed : Attribute application@appComponentFactory

    集成引入第三方library时出现以下错误

    Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
    

    这是由于AndroidX包和Android support冲突引起的 (打开AndroidStudio下方Terminal输入命令gradlew :app:dependencies可以看到包结构)

    |    +--- com.android.support:support-vector-drawable:28.0.0
    |    |    +--- com.android.support:support-annotations:28.0.0
    |    |    \--- com.android.support:support-compat:28.0.0 (*)
    |    \--- com.android.support:animated-vector-drawable:28.0.0
    |         +--- com.android.support:support-vector-drawable:28.0.0 (*)
    |         \--- com.android.support:support-core-ui:28.0.0 (*)
    +--- com.android.support.constraint:constraint-layout:1.1.3
    |    \--- com.android.support.constraint:constraint-layout-solver:1.1.3
    +--- com.jakewharton:butterknife:10.1.0
    |    \--- com.jakewharton:butterknife-runtime:10.1.0
    |         +--- com.jakewharton:butterknife-annotations:10.1.0
    |         |    \--- androidx.annotation:annotation:1.0.0
    |         \--- androidx.core:core:1.0.0
    |              +--- androidx.annotation:annotation:1.0.0
    |              +--- androidx.collection:collection:1.0.0
    |              |    \--- androidx.annotation:annotation:1.0.0
    |              +--- androidx.lifecycle:lifecycle-runtime:2.0.0
    |              |    +--- androidx.lifecycle:lifecycle-common:2.0.0
    
    
    Gradle: android.arch.core:common:1.1.1@jar
    Gradle: android.arch.core:runtime:1.1.1@aar
    Gradle: android.arch.lifecycle:common:1.1.1@jar
    Gradle: android.arch.lifecycle:livedata:1.1.1@aar
    Gradle: android.arch.lifecycle:livedata-core:1.1.1@aar
    Gradle: android.arch.lifecycle:runtime:1.1.1@aar
    Gradle: android.arch.lifecycle:viewmodel:1.1.1@aar
    Gradle: androidx.annotation:annotation:1.0.0@jar
    Gradle: androidx.arch.core:core-common:2.0.0@jar
    Gradle: androidx.collection:collection:1.0.0@jar
    Gradle: androidx.core:core:1.0.0@aar
    Gradle: androidx.lifecycle:lifecycle-common:2.0.0@jar
    Gradle: androidx.lifecycle:lifecycle-runtime:2.0.0@aar
    Gradle: androidx.versionedparcelable:versionedparcelable:1.0.0@aar
    Gradle: com.android.support.constraint:constraint-layout:1.1.3@aar
    Gradle: com.android.support.constraint:constraint-layout-solver:1.1.3@jar
    Gradle: com.android.support.test.espresso:espresso-core:3.0.2@aar
    Gradle: com.android.support.test.espresso:espresso-idling-resource:3.0.2@aar
    Gradle: com.android.support.test:monitor:1.0.2@aar
    Gradle: com.android.support.test:runner:1.0.2@aar
    Gradle: com.android.support:animated-vector-drawable:28.0.0@aar
    Gradle: com.android.support:appcompat-v7:28.0.0@aar
    Gradle: com.android.support:asynclayoutinflater:28.0.0@aar
    Gradle: com.android.support:collections:28.0.0@jar
    Gradle: com.android.support:coordinatorlayout:28.0.0@aar
    Gradle: com.android.support:cursoradapter:28.0.0@aar
    Gradle: com.android.support:customview:28.0.0@aar
    Gradle: com.android.support:documentfile:28.0.0@aar
    Gradle: com.android.support:drawerlayout:28.0.0@aar
    Gradle: com.android.support:interpolator:28.0.0@aar
    Gradle: com.android.support:loader:28.0.0@aar
    Gradle: com.android.support:localbroadcastmanager:28.0.0@aar
    Gradle: com.android.support:print:28.0.0@aar
    Gradle: com.android.support:slidingpanelayout:28.0.0@aar
    Gradle: com.android.support:support-annotations:28.0.0@jar
    Gradle: com.android.support:support-compat:28.0.0@aar
    Gradle: com.android.support:support-core-ui:28.0.0@aar
    Gradle: com.android.support:support-core-utils:28.0.0@aar
    Gradle: com.android.support:support-fragment:28.0.0@aar
    Gradle: com.android.support:support-vector-drawable:28.0.0@aar
    Gradle: com.android.support:swiperefreshlayout:28.0.0@aar
    Gradle: com.android.support:versionedparcelable:28.0.0@aar
    Gradle: com.android.support:viewpager:28.0.0@aar
    Gradle: com.google.code.findbugs:jsr305:2.0.1@jar
    Gradle: com.jakewharton:butterknife:10.1.0@aar
    Gradle: com.jakewharton:butterknife-annotations:10.1.0@jar
    Gradle: com.jakewharton:butterknife-runtime:10.1.0@aar
    Gradle: com.squareup:javawriter:2.1.1@jar
    Gradle: javax.inject:javax.inject:1@jar
    Gradle: junit:junit:4.12@jar
    Gradle: net.sf.kxml:kxml2:2.3.0@jar
    Gradle: org.hamcrest:hamcrest-core:1.3@jar
    Gradle: org.hamcrest:hamcrest-integration:1.3@jar
    Gradle: org.hamcrest:hamcrest-library:1.3@jar
    

    方法1

    在AndroidManifest.xml文件中添加android:appComponentFactory=""(可能会解决问题,但不是在根源上解决问题)

    android:appComponentFactory=""
    tools:replace="android:appComponentFactory"
    

    方法2

    1、首先查看build tools(3.2.0以上), gradle(4.6以上)和依赖库(28.0.0)

    classpath 'com.android.tools.build:gradle:3.3.1'
    
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
    
    compileSdkVersion 28
    implementation 'com.android.support:appcompat-v7:28.0.0'
    

    2、选择工程右键-->Refactor-->Migrate to Androidx--> Do Refactor

    方法3

    把项目中依赖Androidx的库转换为Android support
    在terminal中执行gradlew :app:dependencies命令查看依赖Androidx的库再去找低版本替换

    相关文章

      网友评论

          本文标题:集成引入第三方library时出现错误Manifest merg

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