1

在我的项目中,在我的 app.gradle 文件中添加 Exoplayer 2.10.5 后,我收到此错误:

我的 gradle 版本是 3.5.2

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.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:25:5-171:19 to override.

这是我的 app.gradle 文件:

 dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    def lifecycle_version = '1.1.1'
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"
    //noinspection LifecycleAnnotationProcessorWithJava8
    annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
    implementation 'com.google.dagger:dagger:2.21'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.21'
    implementation 'com.airbnb.android:lottie:2.7.0'
    implementation 'com.squareup.retrofit2:parent:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
    implementation 'com.github.ayalma:ExpandableRecyclerView:0.2.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.github.samanzamani.persiandate:PersianDate:0.7'
    implementation 'com.xw.repo:bubbleseekbar:3.20'
    implementation 'com.yydcdut:sdlv:0.7.6'
    implementation 'com.github.GrenderG:Toasty:1.4.2'
    implementation 'com.ms-square:etsyblur:0.2.1'
    implementation 'com.pes.materialcolorpicker:library:1.2.5'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    //exo player :
    //noinspection GradleDependency
    implementation "com.google.android.exoplayer:exoplayer-hls:$exoplayer_version"
    implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
    implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayer_version"
    implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayer_version"
    //multiDex
    implementation 'com.android.support:multidex:1.0.3'
    //zoomLayout
    implementation 'com.otaliastudios:zoomlayout:1.6.1'
    //Recorder
    implementation 'com.kailashdabhi:om-recorder:1.1.0'
    implementation 'com.cleveroad:audiovisualization:1.0.0'
    implementation 'com.sdsmdg.harjot:croller:1.0.7'
    implementation 'com.github.razerdp:AnimatedPieView:1.2.4'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation project(path: ':persiancalendar')
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    implementation files('libs/ksoap2-android-assembly-2.4-jar-with-dependencies.jar')
    //noinspection DuplicatePlatformClasses
    implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.11'
    }

这是我的 AndroidManifest.xml 文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="ir.sabapp.hefzquran">
    ...
    <application
        android:name=".ui.App"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        //activities ,services , provider
    </application>

</manifest>

当我在 AndroidManifest 文件的应用程序标记中使用tools:replace="android:appComponentFactory"时,会出现此错误:

 Manifest merger failed with multiple errors, see logs

有什么问题 ?

4

1 回答 1

1

清单合并失败:来自 [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 的属性 application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) 也存在于[androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 值=(androidx.core.app.CoreComponentFactory)。建议:将 'tools:replace="android:appComponentFactory"' 添加到 AndroidManifest.xml:25:5-171:19 的元素以覆盖。

我的建议是 - 移至AndroidX. 您可以通过从菜单栏中选择Refactor > Migrate to AndroidX现有项目迁移到 AndroidX。

升级到

 classpath 'com.android.tools.build:gradle:3.6.1'//3.6.3

你的dependencies意愿

 implementation 'androidx.appcompat:appcompat:1.1.0'
 implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
 implementation 'androidx.legacy:legacy-support-v4:1.0.0'
于 2020-05-13T11:39:44.717 回答