Android Studio 1.4 does not allow Android module to depend on Java test modules

I have a Test suite (for my Android application) that can work in the Junit approach (right click on the testClass file and run it) in Android Studio. It depends on the Android module that Robolectric uses. It worked fine until Android Studio 1.3.1.

However, when I switch to Android Studio 1.4, when I synchronize my Gradle file, there is a warning there

Warning:Ignoring dependency of module 'app' on module 'unit-tests'. Java modules cannot depend on Android modules

Thus, my test also cannot be run, since all my Android classes, for example. AppCompat is no longer detected.

Part of my Gradle code as below: app is my android module.

def androidModule = project(':app')

dependencies {
    testCompile androidModule
    //... some other dependency
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:2.4'
    testCompile 'org.mockito:mockito-all:1.9.5'
    //... some other dependency
}

https://code.google.com/p/android/issues/detail?id=188880&q=label%3AReportedBy-Developer&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars.

- , Android Studio 1.4, - Gradle Android Studio 1.4?

+4
1

Android Studio v1.3.1

, Robolectric Android Studio GUI - Android Studio v1.3.1 ( , , ), .

: http://tools.android.com/download/studio/stable

Gradle

Gradle . (.. , settings.gradle local.properties), :

 ./gradlew test
+4

Source: https://habr.com/ru/post/1611560/


All Articles