我想使用CI(Jenkins)自动化Android测试,但是一旦我执行了gradle connectedCheck,我就会收到以下错误:
:app:connectedAndroidTest
Unable to install /Users/asolano/Projects/Mobile/Android/Integration-Test-ATDroidUtils/app/build/outputs/apk/app-debug-androidTest-unaligned.apk
com.android.ddmlib.InstallException: This multi-apk application requires a device with API level 21+
at com.android.ddmlib.Device.installPackages(Device.java:862)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:105)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:132)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
com.android.builder.testing.ConnectedDevice > runTests[SM-G850M - 4.4.4] FAILED
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: This multi-apk application requires a device with API level 21+
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:108)
null
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: This multi-apk application requires a device with API level 21+
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:108)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:132)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.ddmlib.InstallException: This multi-apk application requires a device with API level 21+
at com.android.ddmlib.Device.installPackages(Device.java:862)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:105)
... 8 more
:app:connectedAndroidTest FAILED
这在安装了Android Studio的工作站中运行良好。但是服务器没有安装Android Studio,只有Gradle和Android SDK(工具和其他所有东西)。
我的问题是我在服务器上使用gradle connectedCheck运行测试时缺少什么?使用工作站中的控制台,它们工作正常。
工作站正在使用Android插件版本1.1.0rc-3 Gradle 2.3(与服务器相同)和安装在两者上的android sdks是相同的。
![apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
testOptions{
unitTests.returnDefaultValues = true
}
sourceSets{
instrumentTest.setRoot('src/test/java')
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'junit:junit:4+'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile fileTree(dir: 'libs', include: \['*.jar'\])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'org.roboguice:roboguice:2.0'
compile project(':atdroidutilslib')
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
androidTestCompile fileTree(dir: 'libs', include: \['*.jar'\])
androidTestCompile 'com.android.support:appcompat-v7:21.0.3'
androidTestCompile 'com.googlecode.json-simple:json-simple:1.1'
androidTestCompile 'org.roboguice:roboguice:2.0'
androidTestCompile project(':atdroidutilslib')
}]