包括com.google.android.gms:play-services:4.4.52依赖(对于Android应用中的Google + -Login)我在Jenkins上使用Robotium和JUnit运行测试用例时遇到问题。似乎无论哪个测试用例,测试都失败了,使用了VerifyError(之后我也已经观察过ClassNotFound-和NoClassDefFoundError)。 踪迹:
的VerifyError:
java.lang.VerifyError:org / catrobat / catroid / uitest / content / brick / SetSizeToBrickTest at java.lang.Class.getDeclaredConstructors(Native Method) 在java.lang.Class.getConstructors(Class.java:508) 在android.test.suitebuilder.TestGrouping $ TestCasePredicate.hasValidConstructor(TestGrouping.java:228) 在android.test.suitebuilder.TestGrouping $ TestCasePredicate.apply(TestGrouping.java:217) 在android.test.suitebuilder.TestGrouping $ TestCasePredicate.apply(TestGrouping.java:213) 在android.test.suitebuilder.TestGrouping.select(TestGrouping.java:172) 在android.test.suitebuilder.TestGrouping.selectTestClasses(TestGrouping.java:162) 在android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156) 在android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117) 在android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102) 在android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:358) 在pl.polidea.instrumentation.PolideaInstrumentationTestRunner.onCreate(PolideaInstrumentationTestRunner.java:432) 在android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335) 在android.app.ActivityThread.access $ 1500(ActivityThread.java:135) 在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1256) 在android.os.Handler.dispatchMessage(Handler.java:102) 在android.os.Looper.loop(Looper.java:136) 在android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) 在java.lang.reflect.Method.invoke(Method.java:515) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 在dalvik.system.NativeStart.main(本地方法)
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) 在android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88) 在android.test.ClassPathPackageInfoSource.access $ 000(ClassPathPackageInfoSource.java:39) 在android.test.ClassPathPackageInfoSource $ 1.load(ClassPathPackageInfoSource.java:50) 在android.test.ClassPathPackageInfoSource $ 1.load(ClassPathPackageInfoSource.java:47) 在android.test.SimpleCache.get(SimpleCache.java:31) 在android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72) 在android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48) 在android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61) 在android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55) 在android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156) 在android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117) 在android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102) 在android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:358) 在pl.polidea.instrumentation.PolideaInstrumentationTestRunner.onCreate(PolideaInstrumentationTestRunner.java:432) 在android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335) 在android.app.ActivityThread.access $ 1500(ActivityThread.java:135) 在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1256) 在android.os.Handler.dispatchMessage(Handler.java:102) 在android.os.Looper.loop(Looper.java:136) 在android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) 在java.lang.reflect.Method.invoke(Method.java:515) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) 引起:java.lang.NoClassDefFoundError:org / catrobat / catroid / test / utils / SimulatedSensorManager ......还有27个 引起:java.lang.ClassNotFoundException:没找到类" 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& #34;,zip文件" /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]]
build.gradle文件的(相关部分):
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"
}
在我的设备上(带有Lollipop的Nexus 4)登录Google+时,应用程序本身正在运行,没有任何问题。在Android Studio测试中,似乎也没有这些例外。我已经尝试在测试期间禁用字节码验证,如:
tasks.withType(Test) {
scanForTestClasses = false
include "**/*Test.class"
test {
// set JVM arguments for the test JVM(s)
jvmArgs '-XX:-UseSplitVerifier'
}
}
但我仍然有同样的错误。
另外需要注意的是,我还没有编译当前版本的com.google.android.gms:play-services:7.8.0'或者&com; go.google.android.gms:play-services-plus:7.8.0&#39 ;,因为我们首先需要用AppCompat替换ActionBarSherlock(否则它不会编译)。我还不确定是否需要应用com.google.gms.google-services'插件(似乎没有插件工作) - 我还没有把它包括在内,因为它改变了我们的自动Jenkins测试系统依赖的任务结构。
即使经过数小时的搜索,我也不能理解为什么会这样。