Próbuję zbudować Android testu stosując następujący Gradle plik buildAndroid Gradle build: duplikaty plików podczas pakowania APK license.txt
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
instrumentTestCompile "junit:junit:4.+"
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
instrumentTest.setRoot('tests')
instrumentTest {
java.srcDirs = ['tests/src']
res.srcDirs = ['tests/res']
assets.srcDirs = ['tests/assets']
resources.srcDirs = ['tests/src']
}
}
}
Po uruchomieniu pojawia się następujący błąd:
Error: duplicate files during packaging of APK ... Path in archive: LICENSE.txt Origin 1: ....gradle/caches/artifacts-24/filestore/junit/junit/4.11/jar/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar Origin 2: ....gradle/caches/artifacts-24/filestore/org.hamcrest/hamcrest-core/1.3/jar/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar :packageTest FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':packageTest'. Duplicate files at the same path inside the APK: LICENSE.txt
+1, w sytuacjach bezczynności użycie "junit: junit: 4. +" rozwiąże wszystkie wartości większe niż 4.0, które obejmują 4.5+. Ale studio/gradle ma ten problem, gdy nie odświeża zależności lub szuka nowych zależności w czasie. Obejście problemu polegałoby na zignorowaniu pamięci podręcznej i ponownym załadowaniu zależności. – Varun