Appium 不懂就问,Appium 小白,在启动 app 时遇到 /data/local/tmp/xxx.apk: No such file or directory 问题

AllisonLiu · 2019年07月18日 · 最后由 weigtman 回复于 2019年11月06日 · 3822 次阅读

在用脚本启动 app 时,
console 打出的错误是:

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: Command '/usr/local/android-sdk-macosx/platform-tools/adb -P xxxxx -s xxxxxxx shell ls /data/local/tmp/0001183aa4c4852a5fe987466c77d407.apk' exited with code 1{"stdout":"","stderr":"ls: /data/local/tmp/0001183aa4c4852a5fe987466c77d407.apk: No such file or directory\n","code":1}

appium 详细日志:

[MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: Command '/usr/local/android-sdk-macosx/platform-tools/adb -P xxx -s xxx shell ls /data/local/tmp/0001183aa4c4852a5fe987466c77d407.apk' exited with code 1{"stdout":"","stderr":"ls: /data/local/tmp/0001183aa4c4852a5fe987466c77d407.apk: No such file or directory\n","code":1}
    at ADB.execFunc$ (lib/tools/system-calls.js:189:13)
    at tryCatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at run (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:104:47)
    at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:115:28
    at flush (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/$.microtask.js:19:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

我不太理解,即使真机中不存在该 apk,应该会自动下载一个到真机上,而不是直接抛出该 apk 不存在。

共收到 10 条回复 时间 点赞

应该是 appium push apk 到手机的时候失败了,你往前追一下 appium 日志看看

cmlanche 回复

追看 log,没看到有跟 push apk 操作相关的日志。

AllisonLiu 回复

把代码贴到这里:https://app.niucodata.com/share,我帮你看看

cmlanche 回复

好的,我等会贴上去。谢谢。

cmlanche 回复

大佬你好 遇到了差不多的问题;能跟你请教下吗?谢谢
[MJSONWP] Encountered internal error running command: Error executing adbExec. Original error: 'Command ''E:\Program File\sdk\platform-tools\adb.exe' -P 5037 -s JBVV1V0M10 shell pm install -r /data/local/tmp/appium_cache/0cc1725a60a05dbb5d0d09256f2fc6ece7e3b10f.apk' exited with code 1'; Stderr: 'Error: java.lang.NullPointerException: Attempt to read from null array'; Code: '1'
[MJSONWP] Error: Command ''E:\Program File\sdk\platform-tools\adb.exe' -P 5037 -s JBVV1V0M10 shell pm install -r /data/local/tmp/appium_cache/0cc1725a60a05dbb5d0d09256f2fc6ece7e3b10f.apk' exited with code 1
[MJSONWP] at ChildProcess.proc.on.code (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\teen_process\lib\exec.js:113:19)
[MJSONWP] at ChildProcess.emit (events.js:182:13)
[MJSONWP] at maybeClose (internal/child_process.js:961:16)
[MJSONWP] at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
[HTTP] <-- POST /wd/hub/session 500 25461 ms - 474
[HTTP]
[HTTP] --> DELETE /wd/hub/session
[HTTP] {}
[HTTP] No route found. Setting content type to 'text/plain'
[HTTP] <-- DELETE /wd/hub/session 404 1 ms - 57

AllisonLiu 回复

你好请问这个问题你是怎么解决的呀;遇到同样的问题呢;请教下;谢谢

weigtman 回复

你可以看看/data/local/tmp/appium_cache/0cc1725a60a05dbb5d0d09256f2fc6ece7e3b10f.apk 这个文件是否正常,自己用 adb install 安装这个文件正常不

cmlanche 回复

adb install 正常

cmlanche 回复

方法加个微信么 谢谢啦~

weigtman 回复

remoteAppsCacheLimit 0

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