我还有下一年级

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

当前回答

如果您不打算迁移到AndroidX,请遵循以下步骤

在终端类型gradlew app:dependencies中 当依赖项显示在窗口中后,按Ctrl+f并输入androidX 你会发现所有在内部使用androidx lib的依赖项,你可能不得不降级它或使用替代,以确保它不再在内部使用androidx lib。

其他回答

在可能的情况下,我不想传递到androidX。我得检查一下我最后的改动。我发现新组件是——> lottie 2.8.0

所以我把它降级为:实现'com.airbnb.android:lottie:2.7.0'

这个问题主要发生在旧的依赖项上。

有两种解决方案:

第一个:

更新项目级gradle文件中所有旧的依赖项和类路径。

classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'

第二个:

你的项目迁移到AndroidX

从Android Studio菜单> Refanctor >迁移到AndroidX

谢谢,如果有人从这个答案中得到帮助,请告诉我。

失败原因

你正在使用材料库,这是AndroidX的一部分。 如果你不了解AndroidX,请仔细阅读这个答案。

一个应用程序应该使用AndroidX或旧的Android Support库。 这就是为什么你要面对这个问题。

例如:

在你的gradle中,你正在使用

com.android。appcompat-v7(旧的Android支持库的一部分) com.google.android。material:material (AndroidX的一部分)(com.android.support:design的AndroidX构建工件)

解决方案

所以解决方案是使用AndroidX或旧的支持库。我建议使用AndroidX,因为Android在28.0.0版本之后将不会更新支持库。参见支持库的发布说明。

只需迁移到AndroidX。以下是我对迁移到AndroidX的详细回答。我把答案的必要步骤写在这里。

在迁移之前,强烈建议备份您的项目。

现有的项目

Android Studio >重构菜单>迁移到AndroidX… 它将分析并在底部打开折射窗口。接受要完成的更改。

新项目

把这些标志放在gradle.properties中

android.enableJetifier=true
android.useAndroidX=true

检查@Library映射是否有相等的AndroidX包。

查看“迁移到AndroidX”的官方页面

什么是Jetifier?

只需将这两行代码添加到您的Manifest文件中

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

为了解决这个问题,我建议显式地定义ext变量的版本 在android/build。Gradle你的根项目

ext {
    googlePlayServicesVersion = "16.1.0" // default: "+"
    firebaseVersion = "15.0.2" // default: "+"

    // Other settings
    compileSdkVersion = <Your compile SDK version> // default: 23
    buildToolsVersion = "<Your build tools version>" // default: "23.0.1"
    targetSdkVersion = <Your target SDK version> // default: 23
    supportLibVersion = "<Your support lib version>" // default: 23.1.1
}

参考 https://github.com/zo0r/react-native-push-notification/issues/1109#issuecomment-506414941