繁体   English   中英

如何解决android中的版本冲突错误?

[英]how to solve version conflict error in android?

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "xxxxxxxxxxxxxxxxxxx"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 20
        versionName '6.7'
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        dexOptions {
            javaMaxHeapSize "4g"

        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/droidText.0.2.jar')
    compile files('libs/mail.jar')
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    // compile files('libs/gson-2.2.2.jar')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:recyclerview-v7:27.1.0'
    compile 'com.android.support:appcompat-v7:27.1.0'
    compile 'com.android.support:design:27.1.0'
    compile 'com.android.support:support-core-utils:27.1.0'
    compile 'com.android.support:support-compat:27.1.0'
    compile 'com.android.support:multidex:1.0.1'
    // Glide image library
    compile 'com.google.firebase:firebase-messaging:11.0.4'
    compile 'com.google.android.gms:play-services-location:11.6.0'
    compile 'com.google.android.gms:play-services-places:11.6.0'
    compile 'com.google.android.gms:play-services-maps:11.6.0'
     //implementaion 'com.google.android.gms:play-services:9.0.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.wdullaer:materialdatetimepicker:2.3.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    testCompile 'junit:junit:4.12'
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    compile('org.apache.httpcomponents:httpmime:4.3') {
        exclude module: "httpclient"
    }
    compile('com.google.code.gson:gson:2.2.2') {
        exclude module: "com.google.code.gson"
    }
}
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/ASL2.0'
        exclude '.idea/compiler.xml'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    defaultConfig {
        multiDexEnabled true

    }

}

在这里,我已经定义了带有Firebase和play service相关库的Gradle 以前我使用的是Firebase 9.0.0版本,现在不使用Firebase 9.0.0密钥。 所以我已经更新到新版本,然后开始出现以下问题。 首先,我仅更新了firebase库,但显示了错误,例如playserviceplayservice必须维护相同的版本。 问题是与playservice有关的gradle更改时间。 (错误:任务':app:processDebugGoogleServices'的执行失败。

请通过更新google-services插件的版本来解决版本冲突(有关最新版本的信息, 访问https://bintray.com/android/android-tools/com.google.gms.google-services/ )或将com.google.android.gms的版本更新为9.0.0。

Google服务插件问题是因为您使用的Firebase和Google Play服务版本不同:

compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.google.android.gms:play-services-places:11.6.0'
compile 'com.google.android.gms:play-services-maps:11.6.0'

它应该是:

compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.google.android.gms:play-services-places:11.6.0'
compile 'com.google.android.gms:play-services-maps:11.6.0'

然后,您还需要将apply plugin: 'com.google.gms.google-services'到构建包底部,如下所示:

apply plugin: 'com.android.application'
android {
   ...
}

   ...

dependencies {
   ...
}

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

您还只需要使用一种版本的依赖关系。 在您的项目中,您正在使用:

compile 'com.google.code.gson:gson:2.6.2'

compile('com.google.code.gson:gson:2.2.2') {
    exclude module: "com.google.code.gson"
}

那是多余的。 您只需要使用一个:

compile 'com.google.code.gson:gson:2.6.2'

最后,您不需要添加以下内容:

compile files('libs/droidText.0.2.jar')
compile files('libs/mail.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')

因为以下行已包含所有这些行:

compile fileTree(include: ['*.jar'], dir: 'libs')

暂无
暂无

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

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