org.gradle.api.tasks.TaskExecutionException:任务':app:checkDebugDuplicateClasses'的执行失败

时间:2019-09-25 06:43:07

标签: java android gradle compiler-errors

我刚刚将Android Studio更新到了3.5版。运行App时发生错误。

  

org.gradle.api.tasks.TaskExecutionException:任务执行失败   ':app:checkDebugDuplicateClasses'。

     

原因1:java.util.concurrent.ExecutionException:   java.lang.RuntimeException:重复的类   android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat   在模块classes.jar中找到   (com.android.support:support-compat:28.0.0)和classes.jar   (com.android.support:support-v4:23.3.0)重复的类   在模块中找到android.support.v4.app.ActionBarDrawerToggle   classes.jar(com.android.support:support-core-ui:28.0.0)和   classes.jar(com.android.support:support-v4:23.3.0)重复的类   在模块中找到android.support.v4.app.ActionBarDrawerToggle $ Delegate   classes.jar(com.android.support:support-core-ui:28.0.0)和   classes.jar(com.android.support:support-v4:23.3.0)重复的类   在中找到了android.support.v4.app.ActionBarDrawerToggle $ DelegateProvider   模块classes.jar(com.android.support:support-core-ui:28.0.0)和   classes.jar(com.android.support:support-v4:23.3.0)重复的类   的android.support.v4.app.ActionBarDrawerToggle $ SlideDrawable   模块classes.jar(com.android.support:support-core-ui:28.0.0)和   classes.jar(com.android.support:support-v4:23.3.0)重复的类   在classes.jar模块中找到android.support.v4.app.ActivityCompat   (com.android.support:support-compat:28.0.0)和classes.jar   (com.android.support:support-v4:23.3.0)重复的类   在classes.jar模块中找到android.support.v4.app.ActivityCompat $ 1   (com.android.support:support-compat:28.0.0)和classes.jar   (com.android.support:support-v4:23.3.0)重复的类   android.support.v4.app.ActivityCompat $ OnRequestPermissionsResultCallback   在模块classes.jar中找到   (com.android.support:support-compat:28.0.0)和classes.jar   (com.android.support:support-v4:23.3.0)重复的类   android.support.v4.app.ActivityCompat $ SharedElementCallback21Impl   在模块classes.jar中找到   (com.android.support:support-compat:28.0.0)和classes.jar   (com.android.support:support-v4:23.3.0)

我的礼物:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.alquickstop"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.github.paolorotolo:appintro:4.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

gradle(应用程序):

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.2'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://jitpack.io" }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

2 个答案:

答案 0 :(得分:1)

  

重复的班级   android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat   在模块classes.jar中找到   (com.android.support:support-compat:28.0.0)和classes.jar   (com.android.support:support-v4:23.3.0)重复的类

您应该添加

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

答案 1 :(得分:0)

转到gradle.properties并编写以下两行代码:

android.useAndroidX=true
android.enableJetifier=true

然后清理重建项目,然后运行。