I read there are a lot of extensive answers (like this one ), but the Android world is developing so fast that it seems like they are a bit outdated and the official documentation still applies to Eclipse with ADT.
I am running AS 1.1 and I am trying to configure simple junit tests to run on an emulator without Robolectric. If I do not include junit in my build.gradle , it cannot find @After , @Before and @Test , and I get package org.junit does not exist . After adding
// unit tests androidTestCompile 'junit:junit:4.11'
the error becomes
Error:duplicate files during packaging of APK [...]/app/build/outputs/apk/app-debug-test-unaligned.apk Path in archive: LICENSE.txt Origin 1: [...]/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar Origin 2: [...]/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar You can ignore those files in your build.gradle: android { packagingOptions { exclude 'LICENSE.txt' } }
Following the console prompt, excluding LICENSE.txt, it works, but it looks like a hack. So I'm wondering, maybe I missed something? Thanks.
source share