gradle - Android "has already been added to output" error for jar in a project dependency -
i have android project uses gradle project dependency. dependency project has library jar. when try compile project library compiled twice , error: error:class no.nordicsemi.android.log.logcontract.application has been added output. please remove duplicate copies.
here folder structure files in question:
>projectroot >dfulibrary >libs -nrf-logger-v2.0.jar -build.gradle >logger -build.gradle
this build.gradle dfulibrary dependency:
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') }
this build.gradle logger (main project):
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 class found of nrf-logger-v2.0.jar why being included twice , how can make sure not?
addition
here ../gradlew dependencies return:
_debugapk - ## internal use, not manually configure ## \--- project :dfulibrary _debugcompile - ## internal use, not manually configure ## +--- project :dfulibrary \--- com.android.support:support-v4:+ -> 21.0.2 \--- com.android.support:support-annotations:21.0.2 _releaseapk - ## internal use, not manually configure ## \--- project :dfulibrary _releasecompile - ## internal use, not manually configure ## +--- project :dfulibrary \--- com.android.support:support-v4:+ -> 21.0.2 \--- com.android.support:support-annotations:21.0.2 androidjacocoagent - jacoco agent use coverage data. \--- org.jacoco:org.jacoco.agent:0.7.1.201405082137 failed androidjacocoant - jacoco ant tasks use execute gradle tasks. \--- org.jacoco:org.jacoco.ant:0.7.1.201405082137 failed compile - classpath compiling main sources. \--- project :dfulibrary provided - classpath compiling main sources. \--- com.android.support:support-v4:+ -> 21.0.2 \--- com.android.support:support-annotations:21.0.2
i removed lines had no dependencies.
edit #2 output ./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
bingo, found it.
just interesting , tried find your project @ internet. , started investigation .... :).
the problem hidden @ nrf-logger-v2.0.jar
. contains .java , .class files. solution remove .java files it.
i did total commander. steps:
- rename
nrf-logger-v2.0.jar
nrf-logger-v2.0.zip
; - go inside , remove .java files;
- rename file jar;
gradlew clean build
or build-rebuild project @ android studio- voila
Comments
Post a Comment