我的项目包含例如com.example.something和我将gradle lib项目添加到我的项目中,我知道它具有相同的包。我尝试编译(项目(':插件-android:app')){ 排除群组:' com.example.something' } 但它给出了错误: com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:
无论如何都要添加lib项目,同时排除该包及其下的所有java类?
这是lib项目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.+' }
这是我的项目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
}
}
答案 0 :(得分:0)
希望这会有所帮助 您可以尝试以这种方式排除包裹
if (event.getAction() == MotionEvent.ACTION_UP) {
}
答案 1 :(得分:0)
如果您尝试排除外部jar或包,请尝试这种方式
compile ('com.android.something') {
exclude module: 'name of module'`}
或者如果你想排除类,那就试试吧。
sourceSets {
main {
java {
exclude 'classname.class'
}
}
}