简体   繁体   中英

Dependencies conflict when adding firebase ML-kit

I am getting the following conflict in dependencies in app gardle while adding the firebase ml kit. Don't know how to resolve this ?

依赖冲突

Is this just a warning message or stopping you from build success ?

Anyways excluding com.android.support works as it worked for me in my project.

Posting my gradle important bits and pieces from my project which uses ml-kit with targetSDK 28 and hope these changes works for you too.

Module gradle:

    android{

    defaultConfig {

            /.. bla bla bla ....
            multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
     buildTypes {
            release {
                minifyEnabled false
                //...
            }
        }
     compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }

    configurations.all {   //this piece is important to avoid duplicates
        exclude group: 'com.android.support',
                module: 'support-v4' 
    }

    }


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    implementation('com.android.support:design:28.0.0') {
//        exclude group: 'com.android.support', module: 'support-annotations' 
//  enable this if still issue exists
    }
    implementation 'com.android.support:support-v4:28.0.0'
    implementation('com.android.support:appcompat-v7:28.0.0') {
//        exclude group: 'com.android.support', module: 'support-annotations'
    }
    implementation 'com.android.support:palette-v7:28.0.0'
    implementation 'com.android.support:multidex:1.0.0'
    implementation 'com.google.firebase:firebase-ml-vision:18.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation('com.squareup.retrofit2:retrofit:2.5.0') {
        // exclude Retrofit’s OkHttp dependency module and define your own module import
        exclude module: 'okhttp'
    }
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    // Dependencies for working withRepoContract Architecture components
    // You'll probably have to update the version numbers in guild.gradle (Project)
    implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
    annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
    implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
    annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"

    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'
}
apply plugin: 'com.google.gms.google-services'

Project Gradle :

buildscript {
     repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.2.0' // google-services plugin

        classpath 'com.android.tools.build:gradle:3.3.1'

      }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
ext {
    roomVersion = '1.1.1'
    archLifecycleVersion = '1.1.1'
}

Gradle dependency errors mainly depend on versions we use and internal duplicate libs used by the dependencies. So posted things along with dependencies those worked for me.

Hope this helps for your fix.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM