Glide gradle和firebaseUI无法同步

时间:2017-04-13 13:23:44

标签: android firebase gradle

我正在使用glide和firebase来管理我的上传和下载图像以显示用户个人资料照片,我按照github repo谈论firebaseUI和滑行,在开始时我的项目工作正常我的应用程序gradle是那样:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.android.support:design:25.2.0'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.google.firebase:firebase-storage:10.0.1'
    testCompile 'junit:junit:4.12'

在阅读文档之后,如果我想要包含firebaseUI版本,我需要将与firebase相关的所有编译升级到10.2.0,我这样做了:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.android.support:design:25.2.0'
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'com.google.firebase:firebase-storage:10.2.0'
    compile 'com.firebaseui:firebase-ui:1.2.0'
    testCompile 'junit:junit:4.12'
}

但我在第一次编译时遇到错误:compile 'com.android.support:appcompat-v7:25.2.0'

错误如下:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.2.0, 25.1.1. Examples include com.android.support:animated-vector-drawable:25.2.0 and com.android.support:cardview-v7:25.1.

我的项目gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        classpath 'com.google.gms:google-services:3.0.0'

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

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


task clean(type: Delete) {
    delete rootProject.buildDir
}

在这里需要一些帮助我对此错误感到困惑:S

1 个答案:

答案 0 :(得分:0)

首先,这与 Glide 库无关。

gradle说"这个项目有不同版本的android支持包",所以你必须使用相同版本的所有com.android.support包。例如,您的项目有' 25.2.0'和' 25.1.1'。

我怎样才能做到这一点?将此块放到app level build.gradle

android {
    ...
}
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.2.0'
            }
        }
    }
}
dependencies {
    ...
}

你可以说"但我只是编译我的所有android支持包,其级别为25.2.0"。一些库包括android支持包,25.1.1来自你的依赖。