我最近在我的开发机器上安装了Jenkins,以帮助我了解持续集成/交付的工作原理。
我有一个基本的Android任务设置,可以构建我的应用程序,然后报告lint,PMD,Checkstyle,Findbugs和JUnit(业务逻辑)测试结果。
我还想运行android单元测试(需要模拟器运行的那些),如何设置它?在我将“connectedAndroidTest”添加到要在构建期间运行的gradle命令列表后,我得到以下输出:
17:03:21 :app:connectedDebugAndroidTest FAILED
17:03:21
17:03:21 FAILURE: Build failed with an exception.
17:03:21
17:03:21 * What went wrong:
17:03:21 Execution failed for task ':app:connectedDebugAndroidTest'.
17:03:21 > com.android.builder.testing.api.DeviceException: No connected devices!
17:03:21
17:03:21 * Try:
17:03:21 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
17:03:21
17:03:21 BUILD FAILED
这是预期的,所以我尝试从Android Studio启动模拟器并再次运行Jenkins构建,导致此错误:
17:08:54 :app:connectedDebugAndroidTest
17:08:54 05:08:54 E/SplitApkInstaller: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.zao.testapp.test signatures do not match the previously installed version; ignoring!
17:08:54 Unable to install C:\Program Files (x86)\Jenkins\workspace\testapp\app\build\outputs\apk\app-debug-androidTest.apk
17:08:54 com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.zao.testapp.test signatures do not match the previously installed version; ignoring!
17:08:54 at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:92)
17:08:54 at com.android.ddmlib.Device.installPackages(Device.java:904)
17:08:54 at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:136)
17:08:54 at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:134)
17:08:54 at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:49)
17:08:54 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
17:08:54 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
17:08:54 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
17:08:54 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
17:08:54 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
17:08:54 at java.lang.Thread.run(Thread.java:748)
17:08:54
17:08:54 com.android.builder.testing.ConnectedDevice > runTests[emulator-5554 - 8.0.0] [31mFAILED [0m
17:08:54 com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.zao.testapp.test signatures do not match the previously installed version; ignoring!
17:08:54 at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:144)
17:08:54 [no message defined]
17:08:54 com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.zao.testapp.test signatures do not match the previously installed version; ignoring!
17:08:54 at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:144)
17:08:54 at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:134)
17:08:54 at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:49)
17:08:54 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
17:08:54 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
17:08:54 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
17:08:54 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
17:08:54 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
17:08:54 at java.lang.Thread.run(Thread.java:748)
17:08:54 Caused by: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.zao.testapp.test signatures do not match the previously installed version; ignoring!
17:08:54 at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:92)
17:08:54 at com.android.ddmlib.Device.installPackages(Device.java:904)
17:08:54 at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:136)
17:08:54 ... 8 more
17:08:54 :app:connectedDebugAndroidTest FAILED
17:08:54
17:08:54 FAILURE: Build failed with an exception.
17:08:54
17:08:54 * What went wrong:
17:08:54 Execution failed for task ':app:connectedDebugAndroidTest'.
17:08:54 > There were failing tests. See the report at: file:///C:/Program%20Files%20(x86)/Jenkins/workspace/testapp/app/build/reports/androidTests/connected/index.html
17:08:54
17:08:54 * Try:
17:08:54 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
17:08:54
17:08:54 BUILD FAILED
我还尝试通过任务设置来设置模拟器。我已选中“在构建期间运行Android模拟器”选项。
运行现有模拟器的选项对我不起作用 - 我从我在Android Studio中创建的模拟器中给出了AVD名称,在我的案例中为“Nexus_5X_API_26”,我在构建时遇到以下错误:
17:26:07 FATAL: C:\Windows\system32\config\systemprofile\.android\avd\Nexus_5X_API_26.ini (The system cannot find the path specified)
17:26:07 java.io.FileNotFoundException: C:\Windows\system32\config\systemprofile\.android\avd\Nexus_5X_API_26.ini (The system cannot find the path specified)
这是有道理的,因为我的模拟器位于C:\ Users \ Zach.android \ avd \。
我还尝试使用以下值运行我在配置中指定属性的模拟器:
Android OS version: android-26
Screen density: 420
Screen resolution: 1080x1920
Device locale: en_US
SD card size: <empty>
Target ABI: x86
Emulator name suffix: <empty>
我得到以下输出:
17:31:51 $ D:\Android\sdk/tools/android.bat list target
17:31:52 [android] The configured Android platform needs to be installed: android-26
17:31:52 $ D:\Android\sdk/tools/android.bat list target
17:31:53 $ D:\Android\sdk/tools/android.bat list target
17:31:54 [android] Installing the 'sys-img-x86-android-26' SDK component(s)...
17:31:54 $ D:\Android\sdk/tools/android.bat update sdk -u -a -t sys-img-x86-android-26
17:31:54 **************************************************************************
17:31:54 The "android" command is deprecated.
17:31:54 For manual SDK, AVD, and project management, please use Android Studio.
17:31:54 For command-line tools, use tools\bin\sdkmanager.bat
17:31:54 and tools\bin\avdmanager.bat
17:31:54 **************************************************************************
17:31:54
17:31:54 "android" SDK commands can be translated to sdkmanager commands on a best-effort basis.
17:31:54 (This prompt can be suppressed with the --use-sdk-wrapper commend-line argument
17:31:54 or by setting the USE_SDK_WRAPPER environment variable)
导致Jenkins永远挂起,并在控制台输出视图的最后一行显示忙碌指示符。我被迫中止构建并在此时重新启动Jenkins,以便让构建再次工作。
那么,我在这里错过了什么?为什么这对我来说太难了!任何人都知道如何完成运行Android单元测试 - &gt;得到一个模拟器来启动Jenkins的构建?
编辑:我更新了Jenkins以“我”而不是本地系统帐户运行,并允许我(尝试)使用现有的模拟器,而不是抱怨无法找到它。但是,我现在在尝试启动模拟器时遇到此错误:
00:28:11 $ D:\Android\sdk/tools/android.bat list target
00:28:12 [android] Using Android SDK: D:\Android\sdk
00:28:12 $ D:\Android\sdk/platform-tools/adb.exe start-server
00:28:16 * daemon not running. starting it now at tcp:5847 *
00:28:16 * daemon started successfully *
00:28:16 $ D:\Android\sdk/platform-tools/adb.exe start-server
00:28:16 [android] Starting Android emulator
00:28:16 $ D:\Android\sdk/tools/emulator.exe -engine classic -ports 5688,5689 -report-console tcp:5831,max=60 -avd Nexus_5X_API_26 -no-snapshot-load -no-snapshot-save -no-window
00:28:16 PANIC: Missing emulator engine program for 'x86' CPU.
00:29:21 [android] Emulator did not appear to start; giving up
00:29:21 [android] Stopping Android emulator
00:29:22 $ D:\Android\sdk/platform-tools/adb.exe kill-server
所以我猜这个现在是第一个问题,有什么想法吗?
答案 0 :(得分:0)
我能够通过添加“-engine auto”模拟器选项来实现此功能。
我查看了这个Jenkins问题来帮助解决这个问题:https://issues.jenkins-ci.org/browse/JENKINS-43557