错误重复条目:android / support / v4 / view / GestureDetectorCompat $ GestureDetectorCompatImpl.class,在Android Studio中

时间:2017-06-16 22:20:15

标签: android gradle duplicates google-play-services gesturedetector

我正在使用android studio 2.1.3。这是我的gradle代码:

 buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.1.3'
        }
    }
    apply plugin: 'android'

    dependencies {
        compile fileTree(include: '*.jar', dir: 'libs')
        compile 'com.google.android.gms:play-services-ads:8.3.0'
        compile files('libs/android-support-v4.jar')
    }

    android {
        compileSdkVersion 19
        buildToolsVersion "19.1.0"

        defaultConfig {
            multiDexEnabled true
            minSdkVersion 9
            targetSdkVersion 20
        }

        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }

            instrumentTest.setRoot('tests')

            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
    }

运行时,我收到以下错误:

  

错误:任务执行失败   ':transformClassesWithJarMergingForRelease'

     
    

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:     机器人/支撑/ V4 /视图/ GestureDetectorCompat $ GestureDetectorCompatImpl.class

  

请告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

看起来你来自Eclipse项目。

您不需要支持库的JAR文件。

libs/中删除支持JAR并更新Gradle文件

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile 'com.android.support:appcompat-v7:19+' 
    compile 'com.google.android.gms:play-services-ads:8.3.0'  // Should update this

    // compile files('libs/android-support-v4.jar') // Remove this
  

我正在使用android studio 2.1.3

我建议您升级IDE(和Gradle一起使用时)