android - 遵循Mapbox初学者教程会返回 “Manifest merger failed”错误

标签 android gradle build mapbox manifest

我已经开始一个新项目,我唯一添加的就是Mapbox SDK的依赖项。当我构建项目时,它将产生以下输出:

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'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.xxxx.xxxxxx"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    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.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0'
}

这是我的 list :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.xxx.xxxxxxx">

    <application
        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">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

我没有在该项目中添加任何其他内容,并且按照字母跟随了Mapbox教程。我不明白为什么会这样。我对Gradle不太熟悉,所以很抱歉,如果这是一个明显的问题:)

最佳答案

我认为这次合并失败可能是因为Android版Mapbox Maps SDK使用的是AndroidX,而您仍在使用AppCompat(support:appcompat等)依赖项。

将您的项目过渡到AndroidX? https://developer.android.com/jetpack/androidx/migrate

和/或至少看到将两个与AndroidX相关的标志添加到gradle.properties文件中时会发生什么?:https://developer.android.com/jetpack/androidx/migrate#migrate_an_existing_project_using_android_studio

关于android - 遵循Mapbox初学者教程会返回 “Manifest merger failed”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61307628/

相关文章:

android - .APK 上传失败

java - 将字符串和数字与android中的列表分开

java - 你如何使用 gradle 的 `` exclude`` 来替换依赖项?

gradle - Cucumber-JVM 与 Gradle,如何自动运行测试

android - AOSP的 'lunch'组合是什么意思,需要选择什么?

build - 没有子模块的 gradlew 脚本?

java - 如何获取发送短信的价格

java - 如何在android中发送事件让我们可以选择订阅者?

java - 忽略基于 Spring Boot 配置文件的测试类

delphi - 有 `install all`选项吗?