本文介绍了您应该通过 DependencyResolution 手动设置相同的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:任务:app:preDebugBuild"的执行失败.

Error:Execution failed for task ':app:preDebugBuild'.

Android 依赖项com.google.android.gms:play-services-ads"的编译 (11.8.0) 和运行时 (11.0.4) 类路径的版本不同.您应该通过 DependencyResolution 手动设置相同的版本

我的项目gradle:

My project gradle:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.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()
        google()
    }
}

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

我的模块gradle:

My module gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId 'com.bezets.cityappar'
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 4
        versionName '1.3.0'
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "2g"
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
    }
    productFlavors {
    }

    lintOptions {
        disable 'InvalidPackage'
        abortOnError false
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.android.gms:play-services-ads:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:palette-v7:25.3.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile files('libs/volley.jar')
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.google.firebase:firebase-database:11.0.4'
    compile 'com.google.firebase:firebase-storage:11.0.4'
    compile 'com.google.android.gms:play-services-auth:11.0.4'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.google.android.gms:play-services-location:11.0.4'
    compile 'com.google.maps.android:android-maps-utils:0.4'
    compile 'com.google.firebase:firebase-auth:11.0.4'
    compile 'com.google.firebase:firebase-crash:11.0.4'
    compile 'com.google.firebase:firebase-ads:11.0.4'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    compile 'com.squareup:otto:1.3.6'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.github.paolorotolo:appintro:3.3.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    testCompile 'junit:junit:4.12'
}



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

我该如何修复它的错误?

How can I fix it error?

推荐答案

我的错误跟你的差不多,用这些方法解决了.错误如下所示:

My error is similar with yours, solved with these way.Error is shown below :

Android 依赖项 'com.google.android.gms:play-services-tasks' 对于编译 (11.4.2) 和运行时 (15.0.1) 类路径具有不同的版本.您应该通过 DependencyResolution 手动设置相同的版本

然后在文件 : android/build.gradle 中,我添加了这个脚本:

    allprojects {
       ...

       configurations.all {
           resolutionStrategy.force "com.google.android.gms:play-services- 
           tasks:15.0.1"
        }

    }

这篇关于您应该通过 DependencyResolution 手动设置相同的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 00:28