从android studio中的gradle路径中删除文件/ jar / class

时间:2015-10-19 07:25:57

标签: android android-studio gradle android-gradle build.gradle

我启用了multidex我正在使用org.apache.http.legacy.jar并在我的gradle文件中添加了jumblr gradle路径。我正在异常

Error:Execution failed for task :app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/commons/codec/binary/Base64.class

我认为这是因为jumblr也在使用http legacy库,因此我认为我需要从http legacy library明确删除jumblr gradle path。请告诉我如何从gradle路径中删除特定的文件/ jar /类。

更新

    buildscript {
        repositories {
            mavenCentral()
            maven { url 'https://maven.fabric.io/public' }

        }
        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'

    repositories {
        maven { url 'https://maven.fabric.io/public' }

        maven {
            url "https://repo.commonsware.com.s3.amazonaws.com"
        }
        maven {
            url "https://s3.amazonaws.com/repo.commonsware.com"
        }
    }

    android {
        useLibrary 'org.apache.http.legacy'
        compileSdkVersion 23
        buildToolsVersion "23.0.0"
        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }

        defaultConfig {
            applicationId "com.example.myapp"
            minSdkVersion 17
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            // Enabling multidex support.
            multiDexEnabled true
        }
        buildTypes {
            debug {
                shrinkResources true
            }
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    //    configurations {
    //        all*.exclude group: 'org.apache', module: 'commons'
    //    }
    }

    dependencies {

        // Enabling multidex support.
        compile 'com.android.support:multidex:1.0.1'
        //Other Libraries
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile files('libs/okhttp-2.2.0.jar')
        compile files('libs/okhttp-urlconnection-2.2.0.jar')
        compile files('libs/okio-1.2.0.jar')
        compile files('libs/volley.jar')
        compile files ('org.apache.http.legacy.jar')
        compile files('libs/universal-image-loader-1.9.0.jar')
        compile 'com.google.code.gson:gson:2.3'
        compile 'com.android.support:cardview-v7:23.0.0'
        compile 'com.android.support:recyclerview-v7:23.0.0'
        compile 'com.android.support:appcompat-v7:23.0.0'
        compile 'com.android.support:design:23.0.0'
        compile 'com.jpardogo.materialtabstrip:library:1.1.0'
        compile 'com.pkmmte.view:circularimageview:1.1'
        //    compile 'com.github.satyan:sugar:1.3'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.googlecode.mp4parser:isoparser:1.0.5.4'
        compile 'org.bytedeco:javacv:1.0'
        compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-x86'
        compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-x86'
        compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-arm'
        compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-arm'
        compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
        compile project(':vidEffect')
        //      For Endless adapter
        compile 'com.commonsware.cwac:adapter:1.0.+'
        compile 'com.commonsware.cwac:endless:1.2.3'
        //      For Facebook
        compile 'com.facebook.android:facebook-android-sdk:4.6.0'
        //      For Twitter
        compile('com.twitter.sdk.android:twitter:1.8.0@aar') {
            transitive = true;
        }
        compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
            transitive = true;
        }
        //      For Tumblr
        compile files('libs/signpost-commonshttp4-1.2.jar')
        compile files('libs/signpost-core-1.2.jar')
       compile 'com.google.guava:guava:18.0'
        compile project(':ViewPagerIndicator')
            compile ('com.tumblr:jumblr:0.0.11'){
                transitive = true;
                exclude module: 'Base64';
            }
//Incase we have no choice but to use source code
    //    compile project(':jumblr')
    }

1 个答案:

答案 0 :(得分:5)

我认为你可以使用排除

compile('jumblr.jar') {
    transitive = true;
    exclude module: 'Base64';
}

OR

compile ('com.tumblr:jumblr:0.0.11') {
    transitive = true;
    exclude module: 'Base64';
}