简体   繁体   中英

How to fix error when i import eclipse to android studio?(as compile-time dependency to build.gradle)

when i import project eclipse to android studio. It make error about compile. I want to try fix follow: How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M? But it's not working. please help me!

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/annotation/GuardedBy.class

file build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "vae.vnsupermark.com"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled = true
//        versionCode 1
//        versionName "1.0"
        ndk {
            moduleName "vnsm"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'


    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
   // compile 'com.android.support:appcompat-v7:20.0.0'
//    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.android.gms:play-services:4.0.30'
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/error-reporter.jar')
    //compile files('libs/httpclient-4.0.1.jar')
    compile files('libs/mail.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
}

You should remove

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

because it will still compile the library (and all other jars in libs folder), as apparently it is not deleted from libs folder. After this change, commenting out

//compile files('libs/httpclient-4.0.1.jar')

will really work as you expect :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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