2

我想使用 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 Plugin Version 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')
}]

安卓插件版本

4

0 回答 0