Java 如何修复在尝试实现库时出现的清单合并失败错误?

Java 如何修复在尝试实现库时出现的清单合并失败错误?,java,android,Java,Android,我正在尝试添加ramotion paper onboarding android,出现以下问题 在我的应用程序gradle中,我有这个 implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' and

我正在尝试添加ramotion paper onboarding android,出现以下问题

在我的应用程序gradle中,我有这个

implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.ramotion.paperonboarding:paper-onboarding:1.1.3'
但我得到了这个错误

ERROR: 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:5:5-19:19 to override.
错误:清单合并失败:属性application@appComponentFactory值=(android.support.v4.app.CoreComponentFactory)来自[com.android.support:support compat:28.0.0]AndroidManifest.xml:22:18-91
也出现在[androidx.core:core:1.0.1]AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory)中。
建议:在AndroidManifest.xml:5:5-19:19处的元素中添加“tools:replace=“android:appComponentFactory””以覆盖。

我认为您的库使用的是androidx,它与当前项目具有相同的依赖关系(您的项目使用的是旧的依赖关系,它意味着androidx之前的依赖关系)。当它尝试合并时,会启动冲突,因为它具有来自同一依赖项的不同源。我建议您将项目的依赖项更新到Androidx:)

我希望这对您有用

您必须将android.support迁移到androidx才能使用com.google.android.material.libraries

android.useAndroidX=true
android.enableJetifier=true
在gradle.properties文件中添加以上行

使用以下方法迁移到AndroidX

转到重构--->迁移到AndroidX--->单击迁移按钮并执行折射器

并从androidx包导入类和XML

比如说

活动:

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}
xml:



您是否尝试过错误中给出的建议<代码>建议:添加'tools:replace=“android:appComponentFactory”是的,但是我得到了这个消息,清单合并失败,出现了多个错误,请参阅日志
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>