简体   繁体   中英

how to exclude module in build.gradle(Module app)?

I need to exclude a class which is present in a third party library jar file. i don't know the exact syntax format to exclude a group. i tried the following syntax for excluding a class named XMLConstants.class inside the library "javax.xml.stream.jar".

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/xsdlib-1.5.jar')
compile files('libs/relaxngDatatype-2.2.jar')
compile files('libs/javax.xml.stream.jar'){
    exclude module: 'javax-xml-stream'
}
compile files('libs/pull-parser-2.jar')
compile files('libs/javax.xml.bind.jar')
compile files('libs/java-rt-jar-stubs-1.5.0.jar')
compile files('libs/jaxen-core.jar')
compile files('libs/jaxen-dom4j.jar')
compile files('libs/jaxen-1.1-beta-2.jar')
}

If i use this syntax i am getting the following error.

Error:(52, 0) Could not find method exclude() for arguments [{module=javax-   
xml-stream-XMLConstants}] 

I am new to android so i need to know how to write a syntax to exclude a particular class in a third party library jar file. If there is any other method to do this please suggest. Thanks in advance.

Check this post and also this . Both says that you need to add the excluding class name inside sourceSets .

EDIT : Try it like this. I didn't got any error while compiling.

 sourceSets { main { java { srcDir 'libs' exclude 'org.apache.http.protocol.RequestDate.class' } } } 

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