I'm migrating my android project to gradle build system and I can't import my Android project from my Integration Test Android project.
I'm using multi-project configuration with several android-libraries and it's working great, 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 files look 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.
Has anybody had the same problem? I'd like to include the output of the MyApp project dependency into the classpath of Instrumentation-Tests compilation, but I don't know if that is possible using the android gradle plugin.