Original error: Bad App

I am using the latest version of Appium and i am trying to automate an iOS application.
During execution, i’m facing an error and i tried every possible solution but nothing worked.
Here is my appium log:

[Appium] Welcome to Appium v1.7.1
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] port: 4726
[Appium] Appium REST http interface listener started on 127.0.0.1:4726
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/qateam/Documents/testapp.ipa","automationName":"XCUITest","deviceName":"SharmaAchal’s iPhone","platformName":"iOS","platformVersion":"9.3.2","udid":"5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a"},"capabilities":{"desiredCapabilities":{"app":"/Users/qateam/Documents/testapp.ipa","automationName":"XCUITest","deviceName":"SharmaAchal’s iPhone","platformName":"iOS","platformVersion":"9.3.2","udid":"5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a"},"firstMatch":[{"platformName":"ios"}]}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/qateam/Documents/testapp.ipa","automationName":"XCUITest","deviceName":"SharmaAchal’s iPhone","platformName":"iOS","platformVersion":"9.3.2","udid":"5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a"},null,{"desiredCapabilities":{"app":"/Users/qateam/Documents/testapp.ipa","automationName":"XCUITest","deviceName":"SharmaAchal’s iPhone","platformName":"iOS","platformVersion":"9.3.2","udid":"5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a"},"firstMatch":[{"platformName":"ios"}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1511162408276 (12:50:08 GMT+0530 (IST))
[Appium] Creating new XCUITestDriver (v2.51.1) session
[Appium] Capabilities:
[Appium] app: '/Users/qateam/Documents/testapp.ipa'
[Appium] automationName: 'XCUITest'
[Appium] deviceName: 'SharmaAchal’s iPhone'
[Appium] platformName: 'iOS'
[Appium] platformVersion: '9.3.2'
[Appium] udid: '5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a'
[BaseDriver] Session created with session id: 81e7ca15-9850-43cf-b33a-9503acfd0d9b
[XCUITest] Xcode version set to '9.0' (tools v9.1.0.0.1.1508540944)
[XCUITest] iOS SDK Version set to '11.0'
[BaseDriver] Event 'xcodeDetailsRetrieved' logged at 1511162408647 (12:50:08 GMT+0530 (IST))
[XCUITest] Available devices: 5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a
[XCUITest] Creating iDevice object with udid '5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a'
[XCUITest] Determining device to run tests on: udid: '5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a', real device: true
[BaseDriver] Using local app '/Users/qateam/Documents/testapp.ipa'
[BaseDriver] Copying local zip to tmp dir
[BaseDriver] Unzipping /var/folders/wj/1xr2xx9n219bjr7f_s830yw80000gp/T/20171020-603-1bozsrh.plomg9cnmi/appium-app.zip
[BaseDriver] Testing zip archive: /var/folders/wj/1xr2xx9n219bjr7f_s830yw80000gp/T/20171020-603-1bozsrh.plomg9cnmi/appium-app.zip
[BaseDriver] Test zip archive threw error Error: Command 'unzip -tq /var/folders/wj/1xr2xx9n219bjr7f_s830yw80000gp/T/20171020-603-1bozsrh.plomg9cnmi/appium-app.zip' exited with code 9
[BaseDriver] Stderr: 
[BaseDriver] Stdout: [/var/folders/wj/1xr2xx9n219bjr7f_s830yw80000gp/T/20171020-603-1bozsrh.plomg9cnmi/appium-app.zip] End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of /var/folders/wj/1xr2xx9n219bjr7f_s830yw80000gp/T/20171020-603-1bozsrh.plomg9cnmi/appium-app.zip or /var/folders/wj/1xr2xx9n219bjr7f_s830yw80000gp/T/20171020-603-1bozsrh.plomg9cnmi/appium-app.zip.zip, and cannot find /var/folders/wj/1xr2xx9n219bjr7f_s830yw80000gp/T/20171020-603-1bozsrh.plomg9cnmi/appium-app.zip.ZIP, period. 
[XCUITest] Error: Error testing zip archive, are you sure this is a zip file? at testZipArchive$ (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/helpers.js:213:11) at tryCatch (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) Error: Error testing zip archive, are you sure this is a zip file? at testZipArchive$ (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/helpers.js:213:11) at tryCatch (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[XCUITest] Error: Bad app: /Users/qateam/Documents/testapp.ipa. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. at XCUITestDriver.configureApp$ (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:583:13) at tryCatch (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) Error: Bad app: /Users/qateam/Documents/testapp.ipa. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. at XCUITestDriver.configureApp$ (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:583:13) at tryCatch (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[XCUITest] Not clearing log files. Use `clearSystemFiles` capability to turn on.
[MJSONWP] Encountered internal error running command: Error: Bad app: /Users/qateam/Documents/testapp.ipa. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. at XCUITestDriver.configureApp$ (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:583:13) at tryCatch (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/Applications/Appium 2.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session 500 1012 ms - 316 

And here is my script:

public void appLaunch()
       {
    		IOSDriver driver;
    		
    		DesiredCapabilities capabilities= new DesiredCapabilities();
    		capabilities.setCapability("platformVersion", "9.3.2");
    		capabilities.setCapability("platformName", "iOS");//
    		capabilities.setCapability("deviceName", "SharmaAchal’s iPhone");
    		capabilities.setCapability("automationName", "XCUITest");
    		capabilities.setCapability("udid", "5jikuy65yhjmkoimv47hkjoimv54dbk87d08374a");
    		String apkpath="/Users/qateam/Documents/testapp.ipa";
    		File app=new File(apkpath);
    		capabilities.setCapability("app", app.getAbsolutePath());
    		driver = new IOSDriver(new URL("http://127.0.0.1:4726/wd/hub/"), capabilities);
    		Thread.sleep(10000);
            System.out.println("App Launched!")
}

Anybody, please help!
I have already wasted 2 days on troubleshooting this issue.

DId you try to use the .app instead of .ipa?

Tried but same error :frowning:

  1. Can you try to give the app path as a string, something like that:

capabilities.setCapability(“app”, “/Users/qateam/Documents/testapp.ipa”);

  1. Do you get the same error for simulator?

@menypeled

I tried this way too and getting getting same error on simulator also.