添加firebase ML时gradle构建失败

时间:2018-06-13 06:14:14

标签: android firebase firebase-mlkit

我的项目依赖关系如下:

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

修改原始依赖项后,如下所示:

dependencies {
    implementation 'com.android.support:support-v4:27.0.1'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.0.1'
    implementation 'com.android.support:design:27.0.1'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    implementation 'com.google.android.gms:play-services-wearable:15.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'
    implementation 'com.firebaseui:firebase-ui:2.3.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.gongwen:marqueelibrary:1.1.3'
    implementation 'devlight.io:navigationtabbar:1.2.5'
    implementation 'me.itangqi.waveloadingview:library:0.3.5'
    implementation 'com.yanzhenjie:recyclerview-swipe:1.1.4'
    implementation 'com.squareup.okhttp3:okhttp:3.2.0'
    implementation 'com.squareup.okio:okio:1.7.0'
    implementation 'com.google.firebase:firebase-ml-vision:16.0.0'
    implementation 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.android.application'

然后我添加了firebase ML依赖项,

com.google.firebase:firebase-ml-vision:16.0.0   

Gradle构建失败,给我以下消息:

  

请修改版本冲突,方法是更新google-services插件的版本(https://bintray.com/android/android-tools/com.google.gms.google-services/提供有关最新版本的信息)或将com.google.android.gms版本更新为11.4.2

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

更新以下内容:

compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.google.firebase:firebase-database:11.4.2'
compile 'com.google.firebase:firebase-messaging:11.4.2'

到此:

implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'

同时将google play services API更新为最新版本

在顶级gradle文件中:

变化:

classpath 'com.google.gms:google-services:3.1.0'

到此:

classpath 'com.google.gms:google-services:4.0.1'