簡體   English   中英

混合依賴版本時出錯

[英]Getting error while mixing dependencies versions

我收到如下圖所示的錯誤 錯誤沖突圖像

我嘗試了很多鏈接並檢查了stackoverflow上的內容,並設法解決了大部分但不是全部解決的問題。有沒有更簡單的方法來解決此版本混合的問題。

以下是我的gradle文件

    /**********My Gradle ************************/
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}



android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.example.company"
        minSdkVersion 15
        versionCode 8  //Update on store 25th may 18
        versionName "2.1"

        targetSdkVersion 26
        multiDexEnabled true

    }



    dexOptions {
        javaMaxHeapSize "4g"
    }

    /*buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }*/
    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    useLibrary 'org.apache.http.legacy'

}

dependencies {
    implementation files('libs/jxl-2.6.10.jar')
    /*implementation 'com.android.support:appcompat-v7:23.1.1'*/

    implementation files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')



    implementation 'com.android.support:design:24.2.1'
    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support:cardview-v7:26.0.0'
    implementation 'com.google.android.gms:play-services-basement:10.2.1'
    implementation 'com.google.android.gms:play-services:10.2.1'
    implementation 'com.android.support:support-v4:26.0.0'
    implementation 'com.github.bumptech.glide:glide:3.6.0'
    implementation 'com.android.support:multidex:1.0.0'
    implementation 'com.google.android.gms:play-services-location:9.6.1'
    implementation 'com.google.android.gms:play-services-maps:9.6.1'
    implementation 'com.google.android.gms:play-services:9.6.1'
    implementation 'com.google.android.gms:play-services-identity:9.6.1'
    implementation 'com.google.android.gms:play-services-plus:9.6.1'
    implementation 'com.github.boxme:squarecamera:1.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
//    implementation 'com.google.firebase:firebase-messaging:10.2.1'
    implementation 'com.google.firebase:firebase-messaging:11.0.4'
    implementation 'id.zelory:compressor:2.1.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.android.support:multidex:1.0.0'
    /*implementation 'net.hockeyapp.android:HockeySDK:5.0.1'*/
    implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
        transitive = true;
    }
}

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

以下是我的錯誤日志:

 org.gradle.api.GradleException: Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.1.
    at com.google.gms.googleservices.GoogleServicesTask.checkVersionConflict(GoogleServicesTask.java:161)
    at com.google.gms.googleservices.GoogleServicesTask.action(GoogleServicesTask.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at 

我已經通過下面的帖子,設法解決一些錯誤,但不能完全解決混合依賴版本

請退房。

所有Google依賴項都應具有相同的版本。 將以下內容添加到您的App build.gradle:

configurations.all {

resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    if (details.getRequested().getGroup() == 'com.google.android.gms') {
        // If different projects require different versions of
        // Google Play Services it causes a crash on run.
        // Fix by overriding version for all projects.
        details.useVersion("15.0.1")
    }
  }
}

這是gradle依賴項的工作版本:

// All com.android.support versions the same
implementation 'com.android.support:appcompat-v7:26.1.0' // Don't use variable versions '+'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'

// All com.google.android.gms versions the same
implementation 'com.google.android.gms:play-services-basement:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.android.gms:play-services-plus:15.0.1'

implementation 'com.google.android.gms:play-services:12.0.1' // Don't implement repos multiple times
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.android.support:multidex:1.0.0' // Don't implement repos multiple times
implementation 'com.android.support.constraint:constraint-layout:1.1.0' // Don't use alpha versions

implementation 'com.github.bumptech.glide:glide:3.6.0'
implementation 'com.squareup.picasso:picasso:2.5.2'

implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
/*implementation 'net.hockeyapp.android:HockeySDK:5.0.1'*/

implementation 'com.github.boxme:squarecamera:1.1.0'
implementation 'id.zelory:compressor:2.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
    transitive = true
}

一些提示:

  • 除非您知道自己在做什么,否則請勿使用Alpha或Beta版本
  • 不要使用變量版本名稱(26. +),請使用常量版本名稱(26.0.0)
  • 使用最新版本
  • 分組相同版本的依賴項(com.android.support)

要解決此錯誤 ,您需要對所有Google Play服務使用相同的gradle版本

最好使用最新版本( Go to sdk>tools - Check the Google play services >Update it

對於您的項目,應該使用這些漸變

Google+

com.google.android.gms:play-services-plus:15.0.1

Google帳戶登錄

com.google.android.gms:play-services-auth:15.0.1

Google動作,`基本客戶端庫

com.google.android.gms:play-services-base:15.0.1`

Google登錄

com.google.android.gms:play-services-identity:15.0.1

谷歌分析

com.google.android.gms:play-services-analytics:15.0.2

Google意識

com.google.android.gms:play-services-awareness:15.0.1

Google Cast

com.google.android.gms:play-services-cast:15.0.1

Google雲端訊息

com.google.android.gms:play-services-gcm:15.0.1

Google雲端硬碟

com.google.android.gms:play-services-drive:15.0.1

Google Fit

com.google.android.gms:play-services-fitness:15.0.1

Google位置和活動識別

com.google.android.gms:play-services-location:15.0.1

谷歌地圖

com.google.android.gms:play-services-maps:15.0.1

Google行動廣告

com.google.android.gms:play-services-ads:15.0.1

Google地方信息

com.google.android.gms:play-services-places:15.0.1

移動視覺

com.google.android.gms:play-services-vision:15.0.2

Google附近

com.google.android.gms:play-services-nearby:15.0.1

Google Panorama Viewer

com.google.android.gms:play-services-panorama:15.0.1

Google Play游戲服務

com.google.android.gms:play-services-games:15.0.1

安全網

com.google.android.gms:play-services-safetynet:15.0.1

Android Pay

com.google.android.gms:play-services-wallet:15.0.1

Google穿戴式操作系統

com.google.android.gms:play-services-wearable:15.0.1

參考https://developers.google.com/android/guides/setup

正如您可以檢查依賴項一樣,您正在使用不同版本的Google Play服務和Firebase庫

implementation 'com.google.android.gms:play-services:10.2.1'
implementation 'com.google.android.gms:play-services-location:9.6.1'
implementation 'com.google.firebase:firebase-messaging:11.0.4'

使用相同的版本。

否則,請檢查此官方博客

從所有Play服務和Firebase庫的版本15開始,版本號遵循語義版本控制方案。 不再需要與com.google.android.gms:play-services- *和com.google.firebase:firebase- *匹配的每個Maven依賴項具有相同的版本號,才能在構建時和運行時正常工作。 您將能夠彼此獨立地升級每個依賴項。

將Google Play Gradle插件版本更新為最新版本,當前為3.3。+。

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

並將更新為最新版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM