Manifest marge error after migrating to androidX

南楼画角 提交于 2019-12-22 00:13:14

问题


Recently I have dived into learning new andoirdX artefacts including Android Architecture Components.

After reading through the officials docs and a google code samples I have successfully added the necessary dependencies in both my project and app level Gradle files. They are as follows

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

and

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'androidx.navigation.safeargs'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "_ _ _ _ _ _"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    vectorDrawables.useSupportLibrary = true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'


def lifecycle_version = "2.0.0-beta01"
def room_version = "2.0.0-beta01"
def navigationVersion = '1.0.0-alpha06'
kapt "androidx.room:room-compiler:$room_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

implementation 'androidx.core:core-ktx:1.0.0-alpha1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
implementation "android.arch.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "android.arch.navigation:navigation-ui-ktx:$navigationVersion"

implementation "androidx.room:room-runtime:$room_version"
 }

after giving Gradle sync everything worked fine, however, it showed an error saying "Manifest merge error please see logs for more info"

I have double checked with an app from google repository and everything seems normal.

Please accept my humble appreciation in advance


回答1:


Recently I have run into the same issue, Before giving you the solution I would like to tell you that in recent days, due to fast-paced development tools offered by Google our days-old development technique has changed significantly.

Take jetpack as an example, which is a part of AndroidX, and adding it into your projects requires some necessary steps. Moreover, if you are like me who uses Android studio's dialogs for creating an app, you are likely to have these kinds of issues including the one you have mentioned.

The reason for this is android studio still use Appcompat-v7, androidX on the other hand, uses

androidx.appcompat:appcompat:1.0.0

see the full artifacts listing

Above all, after adding responsible dependencies you need to add these two lines in you gradle.properties file

android.useAndroidX=true
android.enableJetifier=true

Unfortunately, if have come this far you would still probably face

Manifest marge error

this is because your automated layout files still have old classpaths such as

android.support.design.widget.CoordinatorLayout

which should be like this androidx.constraintlayout.widget.ConstraintLayout

this one android.support.design.widget.AppBarLayout should be com.google.android.material.appbar.AppBarLayout and So on.

After rechecking every classpath rebuild your project and everything should be fine.



来源:https://stackoverflow.com/questions/52576072/manifest-marge-error-after-migrating-to-androidx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!