我还有下一年级

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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.google.android.material:material:1.0.0-rc01'
}

但当我想要构建应用程序时,我得到下一个日志:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0-alpha3] 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.

好!去显化并去做:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="ru.chopcode.myapplication">

    <application
        tools:replace="android:appComponentFactory"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    </application>

</manifest>

然后我在我的Logcat中得到这个错误:

Manifest merger failed with multiple errors, see logs that I have Linked with it

当前回答

在我的情况下,我被添加在清单文件'

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

当然是应用标签, 会有用的

其他回答

当我试图将Kotlin-KTX库添加到我的项目时,我遇到了同样的错误。

我尝试AndroidX迁移,问题解决了!

创建新项目并比较构建。并替换了所有Gradle文件

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'

与其他依赖项相同的是在一个新项目中 就像这样

implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'

implementation 'androidx.constraintlayout:constraintlayout:1.1.2'

implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1'

androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'

implementation 'androidx.core:core-ktx:1.0.0-alpha3'

然后固定导入在kotlin文件中使用androidx。

简单的解决方案-迁移到AndroidX

在gradle里。属性,只需添加下面两个脚本

android.useAndroidX=true
android.enableJetifier=true

原因是什么↓

AndroidX中的所有包都位于以字符串AndroidX开头的一致命名空间中。支持库包已映射到相应的androidx中。*包。有关所有旧类和构建构件到新类的完整映射,请参阅包重构页面。

请参阅包重构页面

首先,一定要在manifest标签中添加这一行

xmlns:tools="https://schemas.android.com/tools"

然后在Android studio中添加工具替换建议的工具

1.在app/build.gradle的末尾添加了这些代码:

configurations.all {
   resolutionStrategy.force 'com.android.support:support-v4:28.0.0' 
   // the above lib may be old dependencies version       
    }

2.修改sdk和tools版本至28:

compileSdkVersion 28
buildToolsVersion '28.0.3'
targetSdkVersion  28

3.在你的AndroidManifest.xml文件中,你应该添加两行:

<application
    android:name=".YourApplication"
    android:appComponentFactory="AnyStrings"
    tools:replace="android:appComponentFactory"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar">

或者简单地

进入Refactor (Studio -> Menu -> Refactor) 单击“迁移到AndroidX”。它的工作 这是工作。