【问题标题】:Android - Build error (Manifest merger failed) after updating to API 28 [duplicate]Android - 更新到 API 28 后生成错误(清单合并失败)[重复]
【发布时间】:2019-07-03 20:00:46
【问题描述】:

我正在尝试使用最新的库作为我的要求的一部分。我确实将 gradle 版本升级到 3.1.4 以及所有支持库与匹配的编译和目标 SDK 版本,但是在构建项目时我得到了

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

我的 app-build.gradle 看起来像这样:

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "propelit.actionopps.com.propelit"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 7
    versionName "1.7"
    multiDexEnabled true
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
    useLibrary 'org.apache.http.legacy'

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
}
externalNativeBuild {

}
}
repositories {
mavenCentral()
mavenLocal()
flatDir {
    dirs 'libs'
}
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
implementation(name: 'HERE-sdk', ext: 'aar')
implementation 'com.victor:lib:1.0.4'
implementation 'com.google.code.gson:gson:2.8.5'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:preference-v14:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.github.markushi:circlebutton:1.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5+'
implementation 'com.github.lzyzsd:circleprogress:1.2.1'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.android.support:multidex:1.0.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'

}

apply plugin: 'com.google.gms.google-services'

我的项目级 build.gradle 是这样的

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    maven {
        url 'https://maven.fabric.io/public'
    }
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'
    classpath 'io.fabric.tools:gradle:1.29.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.3.0'
}
}

allprojects {
repositories {
    google()
    jcenter()
    mavenCentral()
    mavenLocal()
    maven { url "https://jitpack.io"
    }
    maven {
        url 'https://maven.google.com/'
    }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

任何人请说明我在这里可能做错了什么?

【问题讨论】:

    标签: android firebase android-gradle-plugin build.gradle androidx


    【解决方案1】:

    由于关于androidx.core.app.CoreComponentFactoryandroid.support.v4.app.CoreComponentFactory 的错误提示,我认为您正在使用来自新AndroidX 和旧Android Support 的库,请在gradle.properties 中添加以下内容:

    android.useAndroidX=true
    android.enableJetifier=true
    

    这应该可以解决这些依赖冲突。希望对您有所帮助!

    【讨论】:

    • 我做到了,它现在没有显示红色下划线,但在构建项目时再次显示我得到这个:` org.gradle.execution.MultipleBuildFailures:构建完成,但失败了 1 次。原因:org.gradle.api.tasks.TaskExecutionException:任务':app:compileDebugJavaWithJavac'的执行失败。引起:org.gradle.api.internal.tasks.compile.CompilationFailedException:编译失败;有关详细信息,请参阅编译器错误输出。`
    • 那么这次的编译器错误是什么?请将其添加到帖子中。
    • 查看此答案并修复 java 编译器下列出的错误或将错误通知我们以便我们提供帮助。 stackoverflow.com/a/50586433/11040422
    • 在我收到的所有活动中error: package android.support.v7.app does not exist
    • @GeekWithGlasses,我刚刚在您的build.gradle 中注意到的另一件事。添加buildToolsVersion "28.0.0" 并同步,如果此编译错误仍然存​​在,请告诉我
    猜你喜欢
    • 1970-01-01
    • 2017-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-21
    • 2020-01-01
    • 1970-01-01
    相关资源
    最近更新 更多