Multi project setup for testing with gradle in android
I'm migrating my android project to gradle. I'm using multi-project
configuration for several android-libraries and it's working ok, but I'm
having a problem setting up my testing project with multi-project
settings. For external reasons I need to continue using this structure.
MyProject/
| settings.gradle
+ MyApp/
| build.gradle
| src
| res
| libs
+ Instrumentation-Tests/
| build.gradle
| src
| res
| libs
my current configuration looks like:
settings.gradle:
include ':MyApp', 'Instrumentation-Tests'
MyAppp/build.gradle:
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile files('.....jar')
compile project('....')
compile 'com.android.support:support-v4:13.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
And finally my Instrumentation-Tests/build.gradle
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile project(':MyApp')
compile files('.....jar')
compile 'com.android.support:support-v4:13.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
When I run 'gradle compileDebug' the project MyApp is compiled correctly
(and all its modules) but the Instrumentation-Tests compilation fails
because it can not find the android classes defined in MyApp.
I've read documentation and a lot of posts but I couldn't make it work, I
do also tried using:
compile(project(':MyApp')) { transitive = true }
when declaring the dependency.
Does anybody run the same problem? How can I force to include the output
of the MyApp project dependency into the classpath of
Instrumentation-Tests compilation?
Thanks
No comments:
Post a Comment