android - Android Studio list 合并失败

标签 android gradle kotlin android-gradle-plugin

我是Android开发的新手,但是我一生都无法弄清楚这个错误,因此我尝试了解决方案herehere。我仍然无法让该应用程序运行。

错误是

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.

这是我的 build.gradle 文件
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "n8tivedesigns.com.full_rack_mobile"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    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.google.android.gms:play-services-maps:17.0.0'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}

任何帮助都非常感谢。

最佳答案

在AndroidManifest.xml中的应用程序标签上添加tools:replace="android:appComponentFactory"并将xmlns:tools="http://schemas.android.com/tools"添加到 list 标签

例:

    <?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="(..)">

<application
        android:name=".YourApp"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@drawable/ic_launcher_rounded"
        android:supportsRtl="true"
        tools:replace="android:appComponentFactory"

关于android - Android Studio list 合并失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56707868/

相关文章:

Android GridView 选中项背景

android - 根据设备屏幕宽度/高度指定布局中 View 的相对尺寸

android-studio - Gradle 同步错误 - 从 Unity 将 Gradle 项目导入 Android Studio

java - 测试的 Gradle 依赖项与编译的不同

Android Gradle 下载库不完整

android - 创建一个从解析的 XML URL 返回结果的异步任务类

php - 如何从 onesignal 发送推送通知,设备 ID 存储在数据库中 - cordova 应用程序

android - 命令 “./gradlew build connectedCheck”以1退出

kotlin - .indices 在 kotlin 中的含义是什么?

collections - find 和 firstOrNull 有什么区别?