Android-更新到API 28后出现构建错误(清单合并失败)

时间:2019-07-03 20:00:46

标签: android android-gradle build.gradle

我正在尝试使用最新的库作为我的要求的一部分。我确实将gradle版本升级到了3.1.4,并且所有支持库都具有匹配的compile和target SDK版本,但是在构建项目时,我得到

  

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

我的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
}

enter image description here

有人请告诉我我在这里做错了什么吗?

1 个答案:

答案 0 :(得分:0)

由于我认为您同时使用了新AndroidX和旧Android Support的库,而错误提示了androidx.core.app.CoreComponentFactoryandroid.support.v4.app.CoreComponentFactory,因此请在gradle.properties

android.useAndroidX=true
android.enableJetifier=true

这应该解决这些依赖关系冲突。希望对您有帮助!