我想 java 运行自动安装.ipa 包,之前看过大师的帖子,指定.ipa 地址和 udid 就可以,试了一下还是不行,不是.app 的包,是签名过的.ipa 包,手动安装没有问题!

Appium GUI 安装,安装失败

Java code 安装,安装失败,指定.ipa 包地址和 udid

DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("appium-version", "1.0");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "8.4");
        capabilities.setCapability("deviceName", "iPhone 5c");
        capabilities.setCapability("app", "/Users/eternally/Downloads/testscoe7.9.2(v3开发者证书测试接口).ipa");
        capabilities.setCapability("udid","27914dfb88cedd20976995846287ac8b63d9eee7");
        driver = new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
appium 出错日志:
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}

info: [debug] [INST STDERR] 2015-08-17 16:46:05.371 instruments[37340:9212935] WebKit Threading Violation - initial use of WebKit from a secondary thread.

info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 4.) : Failed to launch process with bundle identifier 'com.test.SeeTest'

info: [debug] [INSTSERVER] Instruments exited with code 253

info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] We exceeded the number of retries allowed for instruments to successfully start; failing launch
info: [debug] Stopping iOS log capture
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killing any other simulator daemons
info: [debug] Killall iOS Simulator

info: [debug] On a real device; cannot clean device state

error: Failed to start an Appium session, err was: Error: Instruments crashed on startup

info: [debug] Cleaning up appium session
info: [debug] Error: Instruments crashed on startup
    at [object Object].Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:440:31)
    at [object Object].<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:353:12)
    at ChildProcess.emit (events.js:110:17)
    at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}
info: <-- POST /wd/hub/session 500 29151.300 ms - 182 

解决方法及排查过程:

  1. 手动安装是否成功,如果不成功多半是包签名问题,不是开发者证书打的包
  2. 解压.ipa 包,右键 app 显示包内容,安装.app 是否成功,如果.app 成功可进行下一步排查
  3. 勾选 show iOS system log, Log Level:Debug ,Prelanch Application,查看 log 异常,捕捉异常
  4. 终端运行:/Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w 27914dfb88cedd20976995846287ac8b63d9eee7 com.soufun.SoufunBasic -e UIASCRIPT "/Users/eternally/Library/Application Support/appium/bootstrap/bootstrap-6745615c424bb0c0.js" -e UIARESULTSPATH /tmp/appium-instruments
  5. 最后 ideviceinstaller -i [ipa 文件] -o [设备 udid] 查出 ipa 文件名命名的问题,不能包含()符号,改下名字全英文的就可以了~


↙↙↙阅读原文可查看相关链接,并与作者交流