Gradle android build multi module (Robotium)


(Felix Thomas) #1

I have a Android Project structure as below with individual build scripts in each module. I’m using Gradle version 1.12

-/wl-new
          -/wl-new-app
                   -/build.gradle
                  -/wl-new-test-robotiumtest
                      -/build.gradle
  -settings.gradle
-build.gradle

When I do a gradle build from command line I get the below error.

D:\wl-new\wl-new-test-robotiumtest\src\main\java\com\company\robotium\SampleTest.java:4: error: cannot find symbol import com.company.HelloAndroidActivity;

^

symbol:

class HelloAndroidActivity

location: package com.company D:\wl-new\wl-new-test-robotiumtest\src\main\java\com\company\robotium\SampleTest.java:5: error: package com.jayway.android.robotium.solo does not exist import com.jayway.android.robotium.solo.Solo;

^ D:\wl-new\wl-new-test-robotiumtest\src\main\java\com\company\robotium\SampleTest.java:10: error: cannot find symbol

ActivityInstrumentationTestCase2 {

^

symbol: class HelloAndroidActivity D:\wl-new\wl-new-test-robotiumtest\src\main\java\com\company\robotium\SampleTest.java:12: error: cannot find symbol

private Solo solo;

^

symbol:

class Solo

location: class SampleTest D:\wl-new\wl-new-test-robotiumtest\src\main\java\com\company\robotium\SampleTest.java:15: error: cannot find symbol

super(HelloAndroidActivity.class);

^

symbol:

class HelloAndroidActivity

location: class SampleTest D:\wl-new\wl-new-test-robotiumtest\src\main\java\com\company\robotium\SampleTest.java:19: error: cannot find symbol

solo = new Solo(getInstrumentation(), getActivity());

^

symbol:

class Solo

location: class SampleTest 6 errors :wl-new-test-robotiumtest:compileDebugJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:wl-new-test-robotiumtest:compileDebugJava’. > Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

wl-new-app module is not get refrenced in the robotuium module. I have added the below also in the individual build script. But still same error.

apply plugin: 'com.android.application'
  android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"
      defaultConfig {
        applicationId "com.company.robotium"
         minSdkVersion 19
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
  dependencies {
    compile project(':wl-new-app')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile ('com.squareup:fest-android:1.0.+')
    androidTestCompile ('junit:junit:4.11')
    androidTestCompile ('com.jayway.android.robotium:robotium-solo:4.3')
  }

Am I doing something wrong? Or do I have to use one build.gradle scripts for all modules?