我有一个
Android项目,使用gradle与另一个项目作为依赖.依赖项目有一个库jar.当我尝试编译的项目库被编译了两次,我得到错误:
错误:类no.nordicsemi.android.log.LogContract.Application已经添加到输出.请删除重复的副本.
错误:类no.nordicsemi.android.log.LogContract.Application已经添加到输出.请删除重复的副本.
>ProjectRoot >dFULibrary >libs -nrf-logger-v2.0.jar -build.gradle >Logger -build.gradle
这是dFULibrary依赖的build.gradle:
apply plugin: 'com.android.library' android { compileSdkVersion 19 buildToolsVersion "19.1.0" defaultConfig { applicationId "no.nordicsemi.android.dfu" minSdkVersion 18 targetSdkVersion 19 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt' } } } dependencies { compile 'com.android.support:support-v4:+' compile files('libs/nrf-logger-v2.0.jar') }
这是Logger(主项目)的build.gradle:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.14.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 20 buildToolsVersion '20' sourceSets { main { java.srcDirs "src/main/java" res.srcDirs "src/main/res" assets.srcDirs = ['assets'] } androidTest.setRoot('tests') androidTest.java.srcDirs = ['tests/src'] } dexOptions { preDexLibraries = false } } dependencies { compile 'com.android.support:support-v4:+' compile project':dFULibrary') }
no.nordicsemi.android.log.LogContract.Application类被发现nrf-logger-v2.0.jar为什么被包含两次,我该如何确定它不?
加成
这是什么../gradlew依赖返回:
_debugApk - ## Internal use,do not manually configure ## \--- project :dFULibrary _debugCompile - ## Internal use,do not manually configure ## +--- project :dFULibrary \--- com.android.support:support-v4:+ -> 21.0.2 \--- com.android.support:support-annotations:21.0.2 _releaseApk - ## Internal use,do not manually configure ## \--- project :dFULibrary _releaseCompile - ## Internal use,do not manually configure ## +--- project :dFULibrary \--- com.android.support:support-v4:+ -> 21.0.2 \--- com.android.support:support-annotations:21.0.2 androidJacocoAgent - The Jacoco agent to use to get coverage data. \--- org.jacoco:org.jacoco.agent:0.7.1.201405082137 Failed androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks. \--- org.jacoco:org.jacoco.ant:0.7.1.201405082137 Failed compile - Classpath for compiling the main sources. \--- project :dFULibrary provided - Classpath for only compiling the main sources. \--- com.android.support:support-v4:+ -> 21.0.2 \--- com.android.support:support-annotations:21.0.2
我删除了所有没有依赖关系的行.
编辑#2输出从./gradlew androidDependencies
:DFULibrary:androidDependencies debug \--- LOCAL: nrf-logger-v2.0.jar debugTest +--- LOCAL: nrf-logger-v2.0.jar \--- debug \--- LOCAL: nrf-logger-v2.0.jar release \--- LOCAL: nrf-logger-v2.0.jar :nRFToolBox:androidDependencies debug +--- LOCAL: achartengine-1.1.0.jar \--- nrfToolBox:DFULibrary:unspecified \--- LOCAL: nrf-logger-v2.0.jar debugTest No dependencies release +--- LOCAL: achartengine-1.1.0.jar \--- nrfToolBox:DFULibrary:unspecified \--- LOCAL: nrf-logger-v2.0.jar BUILD SUCCESSFUL