使用 android gradle 插件2.2.0
:
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.android.tools.build:gradle:2.2.0"
}
}
并运行./gradlew assembleDebug assembleDebugAndroidTest
:
与2.2.0
:
app-debug.apk
app-debug-androidTest.apk
与2.1.3
:
app-debug.apk
app-debug-unaligned.apk
app-debug-androidTest.apk
app-debug-androidTest-unaligned.apk
基于这个谷歌问题:https ://code.google.com/p/android/issues/detail?id=212591并在这里评论:https ://code.google.com/p/android/issues/detail?id =212591#c15:
嗨,我们不再生成未对齐的 apk。作为提高速度的一部分,我们生成了已经对齐的 apk。所以,而不是两个,你只得到最后一个。
Spoon 需要这些“未对齐”的 apk 来运行它的测试运行器:
java -jar spoon-runner-1.7.0-jar-with-dependencies.jar \
--debug --fail-on-failure --adb-timeout 90 --no-animations \
--apk app-debug.apk \
--test-apk app-debug-androidTest-unaligned.apk
错误:
12:06:48 I/InstrumentationResultParser: test run failed: 'Instrumentation run failed due to 'java.lang.NoClassDefFoundError''
2016-09-23 12:06:48 [STRL.testRunStarted] testCount=0 runName=<>.test
2016-09-23 12:06:48 [STRL.testRunFailed] errorMessage=Instrumentation run failed due to 'java.lang.NoClassDefFoundError'
2016-09-23 12:06:48 [STRL.testRunEnded] elapsedTime=0
12:06:48 I/XmlResultReporter: XML test result file generated at /<>/spoon-output/junit-reports/emulator-5554.xml. Total tests 0,
看起来 Spoon 只接受“未对齐”。
Exception in thread "main" java.lang.IllegalArgumentException: Instrumentation APK path does not exist.
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
at com.squareup.spoon.SpoonRunner$Builder.setInstrumentationApk(SpoonRunner.java:360)
at com.squareup.spoon.SpoonRunner.main(SpoonRunner.java:657)