Appium [已解决] Appium for iOS, 无法自动安装.ipa  签名包

蝴蝶 · 2015年08月17日 · 最后由 lei 回复于 2017年01月03日 · 2218 次阅读

我想 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 文件名命名的问题,不能包含()符号,改下名字全英文的就可以了~
共收到 21 条回复 时间 点赞

Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 4.) : Failed to launch process with bundle identifier 'com.test.SeeTest'

bundle id 不对

#3 楼 @lihuazhang 手机没有安装这个包啊,不用指定 bundle id 吧,我也没指定呀,只指定.ipa 地址和 udid

这是完整的 log 吗?

麻烦给出详细的 appium server log(从接收到 --> POST wd/hub/session 开始)。
从这个日志里面我们只能看出 bundle id 不对。

PS:bundle id 是必须的,你没有指定的话 appium 自己会去解析 app 来获取。

#6 楼 @chenhengjie123 @sanlengjingvv

出错日志贴上了,还是没有自动安装啊....

PS:bundle id 是必须的,你没有指定的话 appium 自己会去解析 app 来获取。

我记得是如果手机安装了 app 就指定 bundle id,如果未安装 app,就指定 app 路径,这样:“ capabilities.setCapability("app", "/Users/eternally/Downloads/testscoe7.9.2(v3 开发者证书测试接口).ipa"); ” 所以不用指定 bundle id 吧,我想自动安装 app。

info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"8.4","app":"/Users/eternally/Downloads/testscoe7.9.2(v3开发者证书测试接口).ipa","platformName":"iOS","deviceName":"iPhone 5c","appium-version":"1.0","udid":"27914dfb88cedd20976995846287ac8b63d9eee7"}}

info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.7.0_79)

info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: [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. : appium-version

info: [debug] Using local .ipa from desired caps: /Users/eternally/Downloads/testscoe7.9.2(v3开发者证书测试接口).ipa
info: [debug] Copying local zip to tmp dir

info: [debug] /Users/eternally/Downloads/soufun7.9.2(v3开发者证书测试接口).ipa copied to /var/folders/4k/rt5zn03x2m51vp44jxm1sx9c0000gn/T/115718-38808-1nh4362/appium-app.zip

info: [debug] Unzipping /var/folders/4k/rt5zn03x2m51vp44jxm1sx9c0000gn/T/115718-38808-1nh4362/appium-app.zip

info: [debug] Testing zip archive: /var/folders/4k/rt5zn03x2m51vp44jxm1sx9c0000gn/T/115718-38808-1nh4362/appium-app.zip

info: [debug] Zip archive tested clean

info: [debug] Unzip successful

info: [debug] Got a relaxed match for app in zip, be careful for app match errors

info: [debug] Using locally extracted app: /var/folders/4k/rt5zn03x2m51vp44jxm1sx9c0000gn/T/115718-38808-1nh4362/Payload/SouFun.app
info: [debug] Creating new appium session 68dc26ba-fb20-4245-a456-12bfe8125038
info: [debug] Removing any remaining instruments sockets

info: [debug] Cleaned up instruments socket /tmp/instruments_sock

info: [debug] Auto-detecting iOS udid...
info: [debug] Not auto-detecting udid, running on sim

info: [debug] Parsed app Info.plist (as binary)
info: [debug] Parsed app Localizable.strings
info: [debug] Getting bundle ID from app
info: [debug] Parsed app Info.plist (as binary)
info: [debug] Creating instruments
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/eternally/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js","instrumentsSock":"/tmp/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"autoDismissAlerts":false,"sendKeyStrategy":"grouped"}

info: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
...

info: [debug] Dynamic bootstrap path: /Users/eternally/Library/Application Support/appium/bootstrap/bootstrap-6745615c424bb0c0.js

info: [debug] Reusing dynamic bootstrap: /Users/eternally/Library/Application Support/appium/bootstrap/bootstrap-6745615c424bb0c0.js

info: [debug] Attempting iOS device log capture via libimobiledevice idevicesyslog

info: [debug] Creating iDevice object with udid 27914dfb88cedd20976995846287ac8b63d9eee7

info: [debug] App is not installed. Will try to install the app.

info: [debug] Installing ipa found at /Users/eternally/Downloads/soufun7.9.2(v3开发者证书测试接口).ipa

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.8","revision":"c8179bd8352d3c62d98fa58b324491230df9342a"},"isShuttingDown":false},"sessionId":"68dc26ba-fb20-4245-a456-12bfe8125038"}

info: <-- GET /wd/hub/status 200 3.074 ms - 178 {"status":0,"value":{"build":{"version":"1.4.8","revision":"c8179bd8352d3c62d98fa58b324491230df9342a"},"isShuttingDown":false},"sessionId":"68dc26ba-fb20-4245-a456-12bfe8125038"}

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.8","revision":"c8179bd8352d3c62d98fa58b324491230df9342a"},"isShuttingDown":false},"sessionId":"68dc26ba-fb20-4245-a456-12bfe8125038"}
info: <-- GET /wd/hub/status 200 1.068 ms - 178 {"status":0,"value":{"build":{"version":"1.4.8","revision":"c8179bd8352d3c62d98fa58b324491230df9342a"},"isShuttingDown":false},"sessionId":"68dc26ba-fb20-4245-a456-12bfe8125038"}

info: [debug] Nothing found on device, going ahead and installing.

info: [debug] Starting command proxy.

info: [debug] Instruments socket server started at /tmp/instruments_sock
info: [debug] Starting instruments

info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID 27914dfb88cedd20976995846287ac8b63d9eee7
info: [debug] Spawning instruments with command: /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
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}

info: [debug] [INST STDERR] 2015-08-18 20:40:31.735 instruments[38822:11414398] 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.soufun.SoufunBasic'

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

info: [debug] Instruments crashed on startup

info: [debug] Attempting to retry launching instruments, this is retry #1
info: [debug] Killall iOS Simulator

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID 27914dfb88cedd20976995846287ac8b63d9eee7

info: [debug] Spawning instruments with command: /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
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}

info: [debug] [INST STDERR] 2015-08-18 20:40:38.999 instruments[38825:11414496] 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.soufun.SoufunBasic'

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

info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #2
info: [debug] Killall iOS Simulator

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID 27914dfb88cedd20976995846287ac8b63d9eee7

info: [debug] Spawning instruments with command: /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
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}

info: [debug] [INST STDERR] 2015-08-18 20:40:45.735 instruments[38828:11414818] 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.soufun.SoufunBasic'

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

info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #3
info: [debug] Killall iOS Simulator

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID 27914dfb88cedd20976995846287ac8b63d9eee7

info: [debug] Spawning instruments with command: /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
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}

info: [debug] [INST STDERR] 2015-08-18 20:40:52.707 instruments[38831:11415026] 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.soufun.SoufunBasic'

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 33548.344 ms - 182 

你这次的错是
error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
发错 log 了吧。
重现下之前的错误。

#8 楼 @sanlengjingvv 之前的错误没有了,从 java 启动就这个样子,第一次启动没反应,第二次启动出错。

蝴蝶 #10 · 2015年08月18日 Author

#8 楼 @sanlengjingvv 重现啦,我把之前的错误日志贴上去了,见 7 楼错误日志,刚更新的哈

蝴蝶 #11 · 2015年08月18日 Author

#7 楼 @hudiefeifei @lihuazhang 见 7 楼错误日志~~~~

1、现在手机上已经有 app 了吧?有的话在 mac 终端运行这段:

/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

输出是什么?

2、解压缩 .ipa 文件,右键 app 显示包内容,有 Info.plist 文件,用 Xcode 打开,Bundle identifier 是什么?

3、签名用的 Provisioning Profiles ,在开发者网站截个图看看。

其实不算重现,因为原来是 com.test.SeeTest 现在是 com.soufun.SoufunBasic

蝴蝶 #13 · 2015年08月19日 Author

#12 楼 @sanlengjingvv 手机上木有 app 啊,没有安装成功

蝴蝶 #14 · 2015年08月19日 Author

#12 楼 @sanlengjingvv 用你的方法,解压缩 .ipa 文件,里面有个.app 包,用这个自动安装成功。直接用.ipa 包不行,好奇怪啊

就算没装 app 也需要 bundleid 的吧,appium 在执行前需要根据 bundleid 校验 app 是否已经安装。

蝴蝶 #16 · 2015年08月19日 Author

#15 楼 @kuroky 不需要,appium 会自己解析这个 bundle id

#16 楼 @hudiefeifei 这个问题你是怎么解决的呀

@hudiefeifei ,楼主解决没呢?怎么解决的,遇到相同的问题,求分享

@hudiefeifei ,楼主我也出现你这样的问题,按照你的方式排查到第 5 步,提示: Error occurred: ApplicationVerificationFailed ,这个是表示什么地方问题?

楼主 我也遇到你这样的问题 使用 ipa 安装到手机失败 而且你手机中安装好的 app 使用 bundleID 提示没找到包 你搞定了吗 求办法

sudo chmod -R 777 /var/db/lockdown/
@woshisunwudi

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