[英]how to add lib project in android studio excluding a specific package from it?
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. 我有我的项目,例如com.example.something包,我正在将gradle lib项目添加到我知道有相同软件包的项目中。 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: 我尝试编译(project(':plugin-android:app')){排除组:'com.example.something'},但它给出了错误:com.android.build.api.transform.TransformException:java.util.zip .ZipException:重复项:
is there anyway to add the lib project while excluding that package and all the java classes under it ? 无论如何,有没有添加lib项目同时排除了该软件包及其下的所有java类?
this is the lib project gradle 这是lib项目的摇篮
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 这是我的项目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
}
}
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/**'
}
}
}
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'
}
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.