简体   繁体   English

混合依赖版本

[英]Mixing dependencies versions

I'm starting to learn develop android apps. 我开始学习开发android应用程序。
I'm following a firebase tutorial, and I'm getting some errors on my build.gradle file. 我正在遵循一个Firebase教程,并且我的build.gradle文件出现一些错误。

Can someone please help me? 有人可以帮帮我吗?

My build.gradle file: 我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "br.com.brunots.firebasetests"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation ''
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    testImplementation 'junit:junit:4.1com.android.support:appcompat-v7:27.1.02'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.android.support:design:27.1.0'
    compile 'com.firebaseui:firebase-ui:0.6.0'
}


apply plugin: 'com.google.gms.google-services'

These are the errors: 这些是错误:

  • All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). 所有gms / firebase库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。 Found versions 9.6.0, 11.8.0. 找到版本9.6.0、11.8.0。 Examples include com.google.android.gms:play-services-auth:9.6.0 and com.google.android.gms:play-services-basement:11.8.0 示例包括com.google.android.gms:play-services-auth:9.6.0com.google.android.gms:play-services-basement:11.8.0
  • All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). 所有com.android.support库都必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。 Found versions 27.1.0, 23.4.0. 找到版本27.1.0,23.4.0。 Examples include com.android.support:animated-vector-drawable:27.1.0 and com.android.support:cardview-v7:23.4.0 示例包括com.android.support:animated-vector-drawable:27.1.0com.android.support:cardview-v7:23.4.0

I don't know where is this the older versions is declared. 我不知道旧版本在哪里声明。

Use classpath 'com.google.gms:google-services:3.2.0' // google-services plugin in your build.gradle(project), then in build.gradle(app) add following firebase dependencies: 在class.gradle(project)中使用classpath 'com.google.gms:google-services:3.2.0' // google-services plugin ,然后在build.gradle(app)中添加以下firebase依赖项:

dependencies {
  compile 'com.google.firebase:firebase-core:11.8.0'
  compile 'com.firebaseui:firebase-ui:11.8.0'}

because when you are using firebase, all its dependencies version must be same. 因为在使用Firebase时,其所有依赖项版本必须相同。 And for the second error, share what you want to achieve, as it is because of version differences. 对于第二个错误,请分享您要实现的目标,这是由于版本差异所致。

This is because you're using firebase-ui version 0.6.0 which is implicitly using firebase and google play service version 9.6.0 (read more about it at https://github.com/firebase/FirebaseUI-Android/releases/tag/0.6.0 ). 这是因为您使用的是Firebase-ui版本0.6.0,即隐式使用了Firebase和Google Play服务版本9.6.0(有关更多信息,请访问https://github.com/firebase/FirebaseUI-Android/releases/tag /0.6.0 )。 So, you can't use the following: 因此,您不能使用以下内容:

implementation 'com.google.firebase:firebase-core:11.8.0'
compile 'com.firebaseui:firebase-ui:0.6.0'

you need to use firebase-ui version 3.2.2 which is using firebase 11.8.0 ( read more at https://github.com/firebase/FirebaseUI-Android ) like this: 您需要使用使用firebase 11.8.0的firebase-ui版本3.2.2(有关更多信息, 参见https://github.com/firebase/FirebaseUI-Android ),如下所示:

implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.firebaseui:firebase-ui:3.2.2'

and you also need to use support library version 27.0.2 for firebase-ui 3.2.2 (look at https://github.com/firebase/FirebaseUI-Android/blob/master/constants.gradle ) 并且您还需要将支持库版本27.0.2用于firebase-ui 3.2.2(请参见https://github.com/firebase/FirebaseUI-Android/blob/master/constants.gradle

Add this to the very end of your build.gradle (Module:app): 将其添加到build.gradle(Module:app)的末尾:

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

Android library versions are supposed to use the same version as your buildToolsVersion which you do not have included. Android库版本应该使用与您未包含的buildToolsVersion相同的版本。 For SDK 27 you should be using 27.0.3. 对于SDK 27,您应该使用27.0.3。 So the android section should start with: 因此,android部分应以以下内容开头:

compileSdkVersion 27
buildToolsVersion "27.0.3"

and the included libraries should end with 并且包含的​​库应以

:27.0.3

I solved that analising the dependency tree: 我解决了解析依赖树的问题:

gradlew app:dependencies

so I saw that conflicts are transitive dependencies of com.firebaseui:firebase-ui-auth:0.6.0 所以我看到冲突是com.firebaseui:firebase-ui-auth:0.6.0可传递依赖项

then i use exclude on my build.glade: 然后我在我的build.glade上使用exclude:

compile ('com.firebaseui:firebase-ui:0.6.0') {
    exclude group: 'com.android.support'
    exclude group: 'com.google.firebase'
    exclude group: 'com.google.android.gms'
}

No more mixing versions :D 没有更多的混合版本:D

configurations.all {
    resolutionStrategy {
        implementation 'com.android.support:design:27.1.0'
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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