Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove file/jar/class from a gradle path in android studio

I have multidex enabled and i am using org.apache.http.legacy.jar and added jumblr gradle path in my gradle file.I am getting exception

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

I think this is because jumblr is also using the http legacy library so i think i need to explicitly remove http legacy library from jumblr gradle path. Kindly let me know on how to remove specific file/jar/class from a gradle path.

Update

    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')
    }
like image 848
Muhammad Umair Shafique Avatar asked Oct 19 '15 07:10

Muhammad Umair Shafique


1 Answers

I think you can use exclude

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

OR

compile ('com.tumblr:jumblr:0.0.11') {
    transitive = true;
    exclude module: 'Base64';
}
like image 99
Niko Adrianus Yuwono Avatar answered Oct 19 '22 10:10

Niko Adrianus Yuwono