suli1 / android-test-kit

Automatically exported from code.google.com/p/android-test-kit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding "androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'" to dependencies causes build to fail

GoogleCodeExporter opened this issue · comments

What steps will reproduce the problem?
1. Create a new android app
2. add "androidTestCompile 
'com.android.support.test.espresso:espresso-core:2.0'" to the dependencies
3. ./gradlew connectedCheck

What version of the product are you using? On what operating system?
Espresso 2.0, gradle 2.2.1, buildtools 21.1.2


Expected: BUILD SUCCESSFUL

Actual Results: FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':testapp:packageDebugTest'.
> Duplicate files copied in APK LICENSE.txt
    File 1: /Users/mike/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.1/860340562250678d1a344907ac75754e259cdb14/hamcrest-core-1.1.jar
    File 2: /Users/mike/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.1/860340562250678d1a344907ac75754e259cdb14/hamcrest-core-1.1.jar


I'm trying to write up the instructions for using espresso for the next version 
of Android App Development for Dummies, but I'm hitting this blocker out of the 
gate.  There are possible workarounds, but it should work out of the box.

Original issue reported on code.google.com by m...@niskala.org on 17 Jan 2015 at 9:53

Yep, the setup instructions as is are wrong. Getting the same error.

Original comment by engappsm...@gmail.com on 25 Jan 2015 at 8:07

[deleted comment]
The issue here is that the jar is getting written twice in one of these files:

        'META-INF/DEPENDENCIES.txt'
        'META-INF/LICENSE.txt'
        'META-INF/NOTICE.txt'
        'META-INF/NOTICE'
        'META-INF/LICENSE'
        'META-INF/DEPENDENCIES'
        'META-INF/notice.txt'
        'META-INF/license.txt'
        'META-INF/dependencies.txt'
        'META-INF/LGPL2.1'
        'LICENSE.txt'
In order to avoid this add the following code you your app module's 
build.gradle inside the android{}:

  packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'LICENSE.txt'
    }
Also, the guide is missing a call to matches() here:

onView(withText("Hello world!")).check(matches(isDisplayed()));.

 If you are running these tests right out of the new project template from Android Studio please note that the default string text for the TextView is "Hello world!" (note the "!"), and the sample test is looking for a View with "Hello world" (no "!")

Original comment by emmanuel...@gmail.com on 9 Mar 2015 at 6:06

Original comment by vale...@google.com on 16 Mar 2015 at 7:42

  • Changed state: Accepted

Original comment by vale...@google.com on 18 Mar 2015 at 5:20

The "..." in the build.gradle example is there to simplify it, although I'll 
add it because this is not the first time this is reported as a bug.

The missing matches() was already added.

And I added the ! to Hello World! to match the new project template from AS.

Original comment by jalc@google.com on 19 Mar 2015 at 5:47

  • Changed state: Fixed