Currently, my android project is using gradle plug-in version 1.2.3. I am able to successfully run the unit tests (android tests) using the gradle command "./gradlew clean connectedProductionAndroidTest" where "Production" is a flavor.
However, when I updated my gradle plug-in to 1.5.0, I am getting the following error.
17:35:16 Tests on Android SDK built for x86 - 4.2 failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'
17:35:16
17:35:16 com.android.builder.testing.ConnectedDevice > No tests found.[Android SDK built for x86 - 4.2] [31mFAILED [0m
17:35:16 No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
When I updated the gradle plug-in, I didn't make any changes to the directory structure nor any of my tests.
Here is the code I am using to update the gradle plug-in. This is in my root build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
I am just wondering if anything has changed between the two versions that might be making my tests fail?
Note that I've placed my tests in "$ROOT/app/src/androidTest/java/..." as specified in the documentation. Also, in gradle 1.2.3, I had to use the command "./gradlew clean connectedProductionAndroidTest" but in plug-in version 1.5.0, it looks like things have changed. I must now do: "./gradlew clean connectedAndroidTestProduction". Note the swap of "Production" and "AndroidTest".
Any help would be greatly appreciated.
EDIT:
Here is my app's build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
lintOptions {
disable 'OldTargetApi'
abortOnError false
}
defaultConfig {
applicationId "com.myapp"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.getVersionCode()
versionName rootProject.getVersionName()
testApplicationId "com.myapp.test"
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles 'proguard.cfg'
signingConfig signingConfigs.release
multiDexEnabled false
}
debug {
debuggable true
testCoverageEnabled true
signingConfig signingConfigs.release
multiDexEnabled true
}
}
productFlavors {
production {
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}