Given a multi-module project with compile dependencies of the main app on
subprojects, adding a androidTestCompile breaks dependencies on other
subprojects.
Given app:build.gradel
dependencies {
compile project(':lib1')
androidTestCompile project(':testfixture')
}
The presence of the androidTestCompile dependency breaks the dependency on
lib1. The project builds, but we get runtime classdef errors for classes
in lib1. It seemed logical I could overcome this by explicitly adding an
androidTestCompile dependency for lib1, and this does compile and run;
however this is broken because production and test code get different
values for resource ID's. For example, R.raw.thing resolves to a different
value in production code than in test code. I assume this has to do with
resource merging and maybe we're getting the wrong build of lib1 somehow.
So, I tried using this syntax which I found in the android doc:
androidTestCompile project(path: ':lib1', configuration: 'debug')
But, of course you probably know that this gives the error that the
configuration is not found. I found the configuration values running
gradlew properties on the lib1 project and tried _debugTestCompile,
debugTestCompile and :lib1:_debugTestCompile; all were also not recognized.
I tried grepping thru the build directory for hints but I merely got older
with no new wisdom.
I'm new to gradle and Android dev so I could be just using things wrong,
but I'm pretty sure this is a bug, or two.
BTW, my driving need is for a subproject that is only included in
androidTest builds - this for code and to solve the problem of test-only
assets or resources. Yes, I found the technique in
https://code.google.com/p/android/issues/detail?id=64887 but it basically
copies assets to the production build which gives us an unreliable build
environment that has to be man-handled a bit to know what you are actually
shipping. This was very undesirable and it didn't work reliably anyway.
If you share a workaround, please be complete in your explanation of how to
use your suggestion - which I would love to hear.
--
You received this message because you are subscribed to the Google Groups
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.