I have an Android application with two layers of library under it. Each library has its own test code. I would like the test code of the upper library to extend the test code of the lower library, but I cannot figure out how to get Gradle to find the test code of the lower libraries (it finds only production code).
My file structure is as follows:
myproject/ + myapp/ + src/ + main/ + java + com/myapp + lib1/ + src/ + main/ + java + com/myapp/lib1 + androidTest + java + com/myapp/lib1/test + lib2/ + src/ + main/ + java + com/myapp/lib2 + androidTest + java + com/myapp/lib2/test
The Gradle file for the application looks like this:
apply plugin: 'com.android.application' android { ... } dependencies { compile project(':lib2') }
The Gradle file for lib2 looks like this:
apply plugin: 'com.android.library' android { ... } dependencies { compile project(':lib1') }
The Gradle file for lib1 looks like this:
apply plugin: 'com.android.library' android { ... }
When I run "gradle connectedCheck", I get the following:
... :lib2:generateDebugTestSources UP-TO-DATE :lib2:compileDebugTestJava myproject/lib2/src/androidTest/java/com/myapp/lib2/test/SubClass.java:10: error: package com.myapp.lib1.test does not exist import com.myapp.lib1.test.BaseClass;
I tried adding various androidTestCompile lines to the dependencies section of the lib2s Gradle file, but none of them help.
Does anyone know how to make this work?
EDIT: Unfortunately, I did not mention that I also have a .gradle option in myproject folder that looks like this:
include ':lib1' include ':lib2' include ':myapp'