尝试通过Appium运行Android集成测试的错误

时间:2014-07-12 15:45:28

标签: java android maven appium

我正在编写一个我正在编写的应用程序的集成测试,我几周前一直在工作,因为我更新了我的Android SDK后一直失败。这个问题似乎不在测试本身,而是与Appium有关。我得到两种不同类型的失败,具体取决于我如何启动Appium实例。

如果我使用从他们的站点安装的Appium.exe,我从命令行工具收到以下消息:

> ERROR: error: Failed to start an Appium session, err was: Error: Could not find zipalign in tools, platform-tools, or supported build-tools under "C:\Program Files (x86)\Android\android-sdk"; do you have android SDK or build-tools installed into this location? Supported build tools are: 17.0.0, 18.0.1, 19.0.0, 19.0.1, android-4.2.2, android-4.3, android-4.4
> warn: UiAutomator did not shut down fast enough, calling it gone
> info: Cleaning up android objects
> info: Cleaning up appium session
> info: Error: Could not find zipalign in tools, platform-tools, or supported build-tools under "C:\Program Files (x86)\Android\android-sdk"; do you have android SDK or build-tools installed into this location? Supported build tools are: 17.0.0, 18.0.1, 19.0.0, 19.0.1, android-4.2.2, android-4.3, android-4.4
>     at ADB.checkSdkBinaryPresent (C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\lib\devices\android\adb.js:94:10)
>     at ADB.checkZipAlignPresent (C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\lib\devices\android\adb.js:137:8)
>     at ADB.zipAlignApk (C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\lib\devices\android\adb.js:451:8)
>     at null.<anonymous> (C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\lib\devices\android\adb.js:445:26)
>     at C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\node_modules\async\lib\async.js:610:21
>     at C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\node_modules\async\lib\async.js:249:17
>     at iterate (C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
>     at C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\node_modules\async\lib\async.js:160:25
>     at C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\node_modules\async\lib\async.js:251:21
>     at C:\AppiumForWindows-0.18.0\Appium\node_modules\appium\node_modules\async\lib\async.js:615:34
> info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find zipalign in tools, platform-tools, or supported build-tools under \"C:\\Program Files (x86)\\Android\\android-sdk\"; do you have android SDK or build-tools installed into this location? Supported build tools are: 17.0.0, 18.0.1, 19.0.0, 19.0.1, android-4.2.2, android-4.3, android-4.4)","origValue":"Could not find zipalign in tools, platform-tools, or supported build-tools under \"C:\\Program Files (x86)\\Android\\android-sdk\"; do you have android SDK or build-tools installed into this location? Supported build tools are: 17.0.0, 18.0.1, 19.0.0, 19.0.1, android-4.2.2, android-4.3, android-4.4"},"sessionId":null}
> POST /wd/hub/session 500 155095ms - 748b

这会导致我的maven构建失败。

如果我通过命令行从我们提取的git存储库运行appium,我从节点服务器收到以下错误:

C:\Appium-Dev\appium>node . --address 127.0.0.1 --platform-name Android --platform-version 17
info: Welcome to Appium v1.2.0 (REV 6b24a459060f8e8352ed4f3a8bcc26b2c507dac5)
info: Appium REST http interface listener started on 127.0.0.1:4723
debug: Non-default server args: {"address":"127.0.0.1","platformName":"Android","platformVersion":"17"}
info: LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"syncstuff-android","app":"C:\\netbeans-workspaces\\syncstuff-android\\syncstuff-andr
debug: The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. :
debug: No appActivity desired capability or server param. Parsing from apk.
debug: No appPackage desired capability or server param. Parsing from apk.
debug: Using local app from desired caps: C:\netbeans-workspaces\syncstuff-android\syncstuff-android-app\target\syncstuff-android-app.apk
debug: Creating new appium session 056709ff-26ba-47fb-84a8-6b15b21da2ec
info: Starting android appium
debug: Using fast reset? true
debug: Preparing device for session
debug: Checking whether app is actually present
debug: Checking whether adb is present
debug: Using adb from C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
info: Retrieving device
debug: Trying to find a connected android device
debug: Getting connected devices...
debug: executing: "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" devices
debug: 1 device(s) connected
info: Found device emulator-5554
debug: Setting device id to emulator-5554
debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
debug: executing: "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" -s emulator-5554 wait-for-device
debug: executing: "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" -s emulator-5554 shell "echo 'ready'"
debug: Starting logcat capture
error: Logcat capture failed: spawn ENOENT
debug: Stopping logcat capture

虽然这个错误没有明确地使我的构建失败,但是在此之后该构建不再做任何事情,直到它在+/- 20分钟后超时。

以下是我的能力

capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "PhoneFourTwo");
capabilities.setCapability("automationName","android-app");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("app-package", "com.companyName");
capabilities.setCapability("app-activity", ".MainActivity");
capabilities.setCapability("takesScreenshot", true);

2 个答案:

答案 0 :(得分:1)

我通过将zip对齐问题复制到工具和平台工具来解决了这个问题。这不是最好的解决方案,而是我所拥有的最佳解决方案。

答案 1 :(得分:0)

昨天在你的SDK文件夹路径中有空格时遇到了同样的问题: C:\ Program Files(x86)\ Android \ android-sdk \ platform-tools \ adb.exe

将SDK文件夹移动到Path,其中没有像C:\ SDK这样的空格或类似的东西。