0

i have my project which has package for example com.example.something and I'm adding gradle lib project to my project which i know has the same package. i try compile (project(':plugin-android:app')) { exclude group: 'com.example.something' } but it gives error: com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:

is there anyway to add the lib project while excluding that package and all the java classes under it ?

this is the lib project gradle

    apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 23
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

}

dependencies {
    compile 'com.android.support:appcompat-v7:23.+' }

and this is example of my project gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "xxx.xxxx.xxxx"
        minSdkVersion 11
        targetSdkVersion 23
        multiDexEnabled true

        ndk {
            moduleName "xxxxx-xxx"
        }
    }
    dexOptions {
        javaMaxHeapSize "2g"
        preDexLibraries true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard.cfg'), 'proguard-rules.txt'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard.cfg'), 'proguard-rules.txt'
        }
        debug {
            jniDebuggable true
            debuggable true
        }
    }

    productFlavors {
        emulator {
        }
        player {
        }
    }

    sourceSets {
        main {
            jni {
            }
        }
        emulator {
        }
        player {
        }
    }

}

dependencies {
    compile "com.google.android.gms:play-services:8.1.0"
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile fileTree(dir: 'src/main/libs', include: ['*.jar'])
    compile (project(':plugin-imagecode-android:app')) {
        //trying to exclude package com.example.something from the lib project
    }
}
nosaiba darwish
  • 1,179
  • 11
  • 13

2 Answers2

0

Hope this helps you can try excluding the package this way

sourceSets {
    main {
        java {
            include 'com/ourcompany/somepackage/activityadapter/**'
            include 'com/ourcompany/someotherpackage/**'
            exclude 'com/ourcompany/someotherpackage/fragment/**'
        }
    }
}
Pooja Nair
  • 113
  • 7
0

if you are trying to exclude external jars or packages try this way

compile ('com.android.something') {
exclude module: 'name of module'`}

or if you want to exclude classes then try this.

sourceSets {
 main {
     java {
         exclude 'classname.class'
     }
 }

}

brahmy adigopula
  • 617
  • 3
  • 15
  • i wanna exclude the class in the lib project only and include the one in my project this won't do so – nosaiba darwish May 11 '16 at 10:47
  • let me see your lib gradle file then only people can understand what do you want to do.add the build.gradle file in qs first. – brahmy adigopula May 11 '16 at 10:51
  • compile project(':library module name') by adding this you can access any class from this module by importing package name..you can't exclude specific package to project module according to my knowledge. – brahmy adigopula May 11 '16 at 11:23
  • http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio refer this link if you still have facing the problem – brahmy adigopula May 11 '16 at 11:31