0

After including com.google.android.gms:play-services:4.4.52 dependency (for Google+-Login within the Android app) I have a problem running the test cases with Robotium and JUnit on Jenkins. It seems that no matter which test case, the test fails with VerifyError (I've also already observed ClassNotFound- and NoClassDefFoundError's afterwards). Stacktraces:

VerifyError:

java.lang.VerifyError: org/catrobat/catroid/uitest/content/brick/SetSizeToBrickTest at java.lang.Class.getDeclaredConstructors(Native Method) at java.lang.Class.getConstructors(Class.java:508) at android.test.suitebuilder.TestGrouping$TestCasePredicate.hasValidConstructor(TestGrouping.java:228) at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:217) at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:213) at android.test.suitebuilder.TestGrouping.select(TestGrouping.java:172) at android.test.suitebuilder.TestGrouping.selectTestClasses(TestGrouping.java:162) at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156) at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117) at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102) at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:358) at pl.polidea.instrumentation.PolideaInstrumentationTestRunner.onCreate(PolideaInstrumentationTestRunner.java:432) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335) at android.app.ActivityThread.access$1500(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)

ClassNotFoundException:

java.lang.ClassNotFoundException: org.catrobat.catroid.test.utils.SimulatedSensorManager at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:251) at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88) at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39) at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50) at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47) at android.test.SimpleCache.get(SimpleCache.java:31) at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72) at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48) at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61) at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55) at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156) at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117) at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102) at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:358) at pl.polidea.instrumentation.PolideaInstrumentationTestRunner.onCreate(PolideaInstrumentationTestRunner.java:432) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335) at android.app.ActivityThread.access$1500(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: org/catrobat/catroid/test/utils/SimulatedSensorManager ... 27 more Caused by: java.lang.ClassNotFoundException: Didn't find class "org.catrobat.catroid.test.utils.SimulatedSensorManager" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/org.catrobat.catroid.test-1.apk", zip file "/data/app/org.catrobat.catroid-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.catrobat.catroid.test-1, /data/app-lib/org.catrobat.catroid-1, /vendor/lib, /system/lib]]

The (relevant part of) build.gradle file:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.1'
        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
        // classpath 'com.google.gms:google-services:1.3.0-beta1'
    }
}

repositories {
    mavenCentral()
}

apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply from: 'gradle/adb_tasks.gradle'
apply from: 'gradle/code_quality_tasks.gradle'
apply from: 'gradle/intellij_config_tasks.gradle'
//apply plugin: 'com.google.gms.google-services'

check.dependsOn 'checkstyle'
check.dependsOn 'pmd'

android {
compileSdkVersion 23
    buildToolsVersion '23.0.0'
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        applicationId 'org.catrobat.catroid'
        testApplicationId "org.catrobat.catroid.test"
        testInstrumentationRunner 'pl.polidea.instrumentation.PolideaInstrumentationTestRunner'
        versionCode 24
        println "VersionCode is " + versionCode
        versionName "0.9.17"
        println "VersionName is " + versionName
        buildConfigField "String", "GIT_DESCRIBE", "\"${versionName}\""
        buildConfigField "String", "GIT_CURRENT_BRANCH", "\"${getCurrentGitBranch()}\""
    }
    defaultConfig {
        multiDexEnabled = true
    }
}


ext {
    projectVersion = "0.9"
}

configurations {
    compile.exclude group: 'xpp3' //compile problem with xstream
    natives
}

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.guava:guava:18.0'
    compile ('com.squareup.okhttp:okhttp:2.3.0') {
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.google.android.gms'
    }
    compile ( 'com.google.code.gson:gson:2.3.1') {
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.google.android.gms'
    }
    compile 'com.github.johnpersano:supertoasts:1.3.4@aar'
    compile 'com.thoughtworks.xstream:xstream:1.4.7'
    def gdxVersion = '1.6.2'
    compile 'com.badlogicgames.gdx:gdx:' + gdxVersion
    compile 'com.badlogicgames.gdx:gdx-backend-android:' + gdxVersion
    natives 'com.badlogicgames.gdx:gdx-platform:' + gdxVersion + ':natives-x86'
    natives 'com.badlogicgames.gdx:gdx-platform:' + gdxVersion + ':natives-armeabi'
    natives 'com.badlogicgames.gdx:gdx-platform:' + gdxVersion + ':natives-armeabi-v7a'
    compile 'com.facebook.android:facebook-android-sdk:4.4.0'  
    compile 'com.google.android.gms:play-services:4.4.52'
    //compile 'com.google.android.gms:play-services-plus:7.8.0'
    //compile 'com.google.android.gms:play-services:7.8.0'
    compile fileTree(include: '*.jar', dir: 'catroid/libs')
    compile fileTree(include: '*.jar', dir: 'catroid/libs-natives')
    androidTestCompile fileTree(include: '*.jar', dir: 'catroidTest/libs')
    androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
    androidTestCompile 'org.mockito:mockito-core:1.10.19'
    pmd 'net.sourceforge.pmd:pmd:5.1.1'
    checkstyle 'com.puppycrawl.tools:checkstyle:6.7'
}

task copyAndroidNatives() {
    file("catroid/jniLibs/armeabi/").mkdirs();
    file("catroid/jniLibs/armeabi-v7a/").mkdirs();
    file("catroid/jniLibs/x86/").mkdirs();
    configurations.natives.files.each { jar ->
        def outputDir = null
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("catroid/jniLibs/armeabi-v7a")
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("catroid/jniLibs/armeabi")
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("catroid/jniLibs/x86")
        if(outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"
            }
        }
    }
}

if (project.hasProperty('jenkins')) {
    project.android.dexOptions.preDexLibraries = false
    project.android.dexOptions.javaMaxHeapSize = "2048M"
} 

On my device (Nexus 4 with Lollipop) The app itself is running without any problems when signing in to Google+. Also within Android Studio tests seem to run without these exceptions. I've already tried to disable bytecode verification during testing like:

tasks.withType(Test) {
    scanForTestClasses = false
    include "**/*Test.class"

test {
        // set JVM arguments for the test JVM(s)
      jvmArgs '-XX:-UseSplitVerifier'
  }
}

but I still had the same errors.

Also to note, I haven't compiled the current version 'com.google.android.gms:play-services:7.8.0' or 'com.google.android.gms:play-services-plus:7.8.0', respectively, because we first need to replace ActionBarSherlock with AppCompat (otherwise it won't compile). I'm also not sure whether I need to apply the 'com.google.gms.google-services' plugin (seems to work without the plugin) - I haven't included it yet because it changes the task structure, where our automated Jenkins test system depends on.

Even after hours of searching I don't really understand why this happens.

Stefan
  • 21
  • 3
  • oh my, `gms:play-services:4.4.52` is really old... and I notice that your `compileSdkVersion` is the newest `23` while your support library is 19.. `compile 'com.android.support:support-v4:19.1.0'` and the google play service is old enough... So you should first make them in one version.. – bjiang Aug 31 '15 at 18:01
  • Thx for your advice and good idea. So we are currently removing ActionBarSherlock.. after that we can take gms:play-services:7:8:0 and the current support lib. – Stefan Sep 01 '15 at 08:55
  • Btw.. I think another mistake is that I switched on multidexing in gradle, but I haven't enabled Multidexing in the Application class. What I'm not sure about.. does multidexing work with robotium and JUnit? – Stefan Sep 01 '15 at 08:57
  • Take look at [here](http://stackoverflow.com/questions/27277285/robotium-android-studio). – bjiang Sep 01 '15 at 16:15

0 Answers0