Appium 【求助问题】appium 安装自动通讯录 apk 失败,困扰好久未解决,请各位帮忙,谢谢

liangyu_2014 · 2014年04月28日 · 最后由 唐僧之妈 回复于 2014年10月11日 · 1410 次阅读

代码用的官网的 AndroidContactsTest.java
模拟器本身安装 apk 正常

当前系统 windows 7

appium 版本 AppiumForWindows-0.17.6

运行脚本后,出现如下错误,

E:\shouji\Appium\node_modules\appium\bin>node appium.js -a127.0.0.1 -p4723 -Uemu
lator-5554 --full-reset
info: Welcome to Appium v0.17.6 (REV 7b32947e166a4338047f31ac14457c2b0eb432aa)
info: Appium REST http interface listener started on 127.0.0.1:4723
info - socket.io started
info: Non-default server args: {"udid":"emulator-5554","address":"127.0.0.1","fu
llReset":true,"merciful":true}
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"platform":"WINDOWS
","app":"D:\workspace\test2\apps\ContactManager.apk","browserName":"","app-p
ackage":"com.example.android.contactmanager","device":"Android","app-activity":"
.ContactManager","version":"4.3"}}
warn: [DEPRECATED] The device capability has been deprecated and will be removed
. Please use the platformName capability instead.
warn: [DEPRECATED] The version capability has been deprecated and will be remove
d. Please use the platformVersion capability instead.
info: Using local app from desired caps: D:\workspace\test2\apps\ContactManager.
apk
info: Creating new appium session 2c945cd2-e33d-4b0f-9226-a90e05dba61b
info: Starting android appium
debug: Using fast reset? false
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
info: [ADB] Using adb from E:\shouji\android-sdk_r22.6-windows\android-sdk-windo
ws\platform-tools\adb.exe
info: Trying to find a connected android device
info: [ADB] Getting connected devices...
debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" devices
info: [ADB] 1 device(s) connected
info: Setting device id to emulator-5554
info: [ADB] Waiting for device to be ready and to respond to shell commands (tim
eout = 5)
debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" -s emulator-5554 wait-for-device
debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" -s emulator-5554 shell "echo 'ready'"
info: Starting logcat capture
info: Getting device API level
debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" -s emulator-5554 shell "getprop ro.build.version.sdk"
info: Device is at API Level 18
debug: java -jar "E:\shouji\Appium\node_modules\appium\lib\devices\android\helpe
rs\strings_from_apk.jar" "D:\workspace\test2\apps\ContactManager.apk" "C:\Window
s\Temp\com.example.android.contactmanager"
warn: Error getting strings.xml from apk
debug: 'java' is not recognized as an internal or external command,
operable program or batch file.

debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" -s emulator-5554 shell "echo '{}' > E:\data\local\tmp\strings
.json"
info: Checking whether aapt is present
info: [ADB] Using aapt from E:\shouji\android-sdk_r22.6-windows\android-sdk-wind
ows\build-tools\19.0.1\aapt.exe
debug: processFromManifest: "E:\shouji\android-sdk_r22.6-windows\android-sdk-win
dows\build-tools\19.0.1\aapt.exe" dump xmltree D:\workspace\test2\apps\ContactMa
nager.apk AndroidManifest.xml
warn: ERROR: dump failed because resource AndroidManifest.xml found

debug: Set app process to: .contactmanager
info: Uninstalling com.example.android.contactmanager
debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" -s emulator-5554 uninstall com.example.android.contactmanager

debug: App was not uninstalled, maybe it wasn't on device?
info: MD5 for app is d4127191869a404fb9f23f7bc7af914a
debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" -s emulator-5554 shell "ls /data/local/tmp/d4127191869a404fb9
f23f7bc7af914a.apk"
debug: Getting install status for com.example.android.contactmanager
debug: executing: "E:\shouji\android-sdk_r22.6-windows\android-sdk-windows\platf
orm-tools\adb.exe" -s emulator-5554 shell "pm list packages -3 com.example.andro
id.contactmanager"
info: [ADB] App is not installed
debug: Checking app cert for D:\workspace\test2\apps\ContactManager.apk: java -j
ar "E:\shouji\Appium\node_modules\appium\lib\devices\android\helpers\verify.jar"
"D:\workspace\test2\apps\ContactManager.apk"
debug: App not signed with debug cert.
debug: Resigning apk with: java -jar "E:\shouji\Appium\node_modules\appium\lib\d
evices\android\helpers\sign.jar" "D:\workspace\test2\apps\ContactManager.apk" --
override
info: Stopping logcat capture
debug: Logcat terminated with code null, signal SIGTERM
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: Cleaning up android objects
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: 'java'
is not recognized as an internal or external command,
operable program or batch file.

info: Error: Command failed: 'java' is not recognized as an internal or external
command,
operable program or batch file.

at ChildProcess.exithandler (child_process.js:637:15)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
info: Responding to client with error: {"status":33,"value":{"message":"A new se
ssion could not be created. (Original error: Command failed: 'java' is not recog
nized as an internal or external command,\r\noperable program or batch file.\r\n
)","killed":false,"code":1,"signal":null,"origValue":"Command failed: 'java' is
not recognized as an internal or external command,\r\noperable program or batch
file.\r\n"},"sessionId":null}
POST /wd/hub/session 500 11744ms - 436b

共收到 8 条回复 时间 点赞

有试过退出 appium 连接吗,然后再重新用 appium 连接模拟器,再执行代码

有退出连接再执行还是一样的问题

也试过在模拟器上手动安装应用,也成功 -------- 应用 apk 本身没问题
但是换了别的 apk 进行执行代码,还是报一样的错误

#1 楼 @careysucci 我看日志连接模拟器的获取设备 id 和 API 也是正确,报的错误找不到 apk 的 string.xml 有什么影响吗?然后就开始报错了。。。

还是得看代码

Java 的环境变量没配置吧

我也遇到这个情况了!不只是 AndroidContacts.apk 其他 apk 也是这样的。怀疑 appium 给 apk 加了签名,然后 apk 被损坏,无法启动 apk

查查 Java 环境变量配置的是否正确

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册