There is something off in 0.9 gradle tool version
src\instrumentTest\java - works on 0.8.+ gradle tool version src\androidTest\java - doesn't work on 0.9.+ gradle tool version
Question
When installing Android Studio 0.5.1 I received the following message:
The project is using an unsupported version of the Android Gradle plug-in (0.7.3). Version 0.9.0 introduced incompatible changes in the build language. Please read the migration guide to learn how to update your project.
I have been trying to migrate my project and the app works just fine but I cannot get my Robotium test cases to run.
This is what I have tried:
- Changed build.gradle from 0.7 to 0.9: classpath 'com.android.tools.build:gradle:0.9.+'
- Updated the gradle-wrapper.properties from distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip to distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
- Following the guide at http://tools.android.com/tech-docs/new-build-system/migrating_to_09 that tells me to rename the testfolder to androidTest and to update test dependencies from instrumentTestCompile to androidTestCompile, i am now using androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.0.1'
My build.gradle file looks like this
apply plugin: 'android'
sourceSets {
main {
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/res']
}
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.2'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 116
versionName "1.5.5"
}
defaultConfig {
testPackageName "com.foo.androidTest"
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'com.jayway.android.robotium:robotium-solo:5.0.1'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.0.1'
}
I do not know what I am missing and all I get when running is:
java.lang.NoClassDefFoundError: com.foo.androidTest.TestSimple$1
at com.foo.androidTest.TestSimple.setUp(TestSimple.java:47)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1740)
And in case you are wondering about the setUp method it looks like this.
45: public void setUp() throws Exception {
46: solo = new Solo(getInstrumentation(), getActivity());
47: falseCondition = new Condition() {
48: @Override
49: public boolean isSatisfied() {
50: return false;
51: }
52: };
53: }
I have not changed any java-code, all I have done is install Android Studio 0.5.1 and then tried to migrate to Gradle 0.9.
Solution
There is something off in 0.9 gradle tool version
src\instrumentTest\java - works on 0.8.+ gradle tool version src\androidTest\java - doesn't work on 0.9.+ gradle tool version