The application at <path> does not exist or is not accessible using Appium - appium

I'm learning appium using eclipse and got stuck on launching my emulator. I tried different things such as moving the file around in the folder structure but I keep getting file does not exist or is not accessible I tried searching for the answer but nothing is helping.
package myAppiumTutorial;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
public class Base {
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
File f = new File("scr");
File fs = new File(f,"ApiDemos-debug.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "MyFirstEmu");
cap.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
AndroidDriver<AndroidElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
Logs from appium
[Appium] Setting automation to 'UiAutomator1'.
[Appium] Appium v1.13.0 creating new AndroidDriver (v4.15.1) session
[Appium] Capabilities:
[Appium] platformName: android
[Appium] app: C:\Users\Zamranj\eclipse-workspaceNew\AppiumIntro\scr\ApiDemos-debug.apk
[Appium] deviceName: MyFirstEmu
[debug] [BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"app":"C:\\Users\\Zamranj\... were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[BaseDriver] Session created with session id: 638fc0a9-1aa0-4b56-ba69-3c854b8e1816
[ADB] Found 1 'build-tools' folders under 'C:\Users\Zamranj\AppData\Local\Android\Sdk' (newest first):
[ADB] C:/Users/Zamranj/AppData/Local/Android/Sdk/build-tools/28.0.3
[ADB] Using 'adb.exe' from 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe'
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Using device: emulator-5554
[ADB] Using 'adb.exe' from 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe'
[debug] [ADB] Setting device id to emulator-5554
[debug] [ADB] Running 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 25
[debug] [ADB] Device API level: 25
[AndroidDriver] Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Called deleteSession but bootstrap wasn't active
[debug] [ADB] Running 'C:\Users\Zamranj\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell am force-stop io.appium.unlock'
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1559218980295 (07:23:00 GMT-0500 (Central Daylight Time))
[debug] [W3C] Encountered internal error running command: Error: The application at 'C:\Users\Zamranj\eclipse-workspaceNew\AppiumIntro\scr\ApiDemos-debug.apk' does not exist or is not accessible
[debug] [W3C] at APPLICATIONS_CACHE_GUARD.acquire (C:\Users\Zamranj\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\helpers.js:159:13)
[HTTP] <-- POST /wd/hub/session 500 2956 ms - 835
[HTTP]
Location of my apk
enter image description here

Your app is not in the src folder.
Instead it is in src/myAppiumTutorial folder.
So in line 17 change the folder to "src/myAppiumTutorial".
And see if it work.

I believe your problem lies with the way you're trying to load your file in.
Try the following:
File f = new File(classLoader.getResource("ApiDemos-debug.apk").getFile());
Please also take a look at the following:
Class.getResource(String)
Class.getResourceAsStream(String)

On Windows 10, I had to use the following double backslash syntax for the .apk file to be found.
caps.setCapability(MobileCapabilityType.APP, "C:\\Users\\Dad\\gitRepos\\myProjects\\AppiumJavaTestNGProject\\src\\test\\resources\\apps\\my.apk");
Only after I did that was the .apk findable by Appium server at runtime. Normally I work on Mac and the pathing is completely different.

Related

Could not acquire lock on uia2_device_port_guard. File already exists

I am new in Appium. I run my app from last 3 weeks by using this code. suddenly when I run this from another class it shows this error in appium server. I do know why it's occurring. I run it in the morning.
public class BaseClass {
public AndroidDriver<AndroidElement> driver;
#BeforeClass
public AndroidDriver<AndroidElement> capabilities() throws MalformedURLException{
File appDir = new File("src/test/resources");
File app = new File(appDir, "KandareeLiteApp.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "emulator-5554");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability("appPackage", "bd.com.cslsoft.kandareeliteapp");
capabilities.setCapability("appActivity","bd.com.cslsoft.kandareeliteapp.view.activities.LauncherActivity");
driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.resetApp();
}
Here is the Appium server-side code-- when start [Logcat] it take so much time.
[W3C] Calling AppiumDriver.createSession() with args: [{"app":"D:\\Automation Project\\Resources\\KandareeLiteApp\\src\\test\\resources\\KandareeLiteApp.apk","appActivity":"bd.com.cslsoft.kandareeliteapp.view.activities.LauncherActivity","appPackage":"bd.com.cslsoft.kandareeliteapp","newCommandTimeout":"100","platformName":"Android","deviceName":"emulator-5554"},null,{"firstMatch":[{"appium:app":"D:\\Automation Project\\Resources\\KandareeLiteApp\\src\\test\\resources\\KandareeLiteApp.apk","appium:appActivity":"bd.com.cslsoft.kandareeliteapp.view.activities.LauncherActivity","appium:appPackage":"bd.com.cslsoft.kandareeliteapp","appium:deviceName":"emulator-5554","appium:newCommandTimeout":"100","platformName":"android"}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1606228007305 (20:26:47 GMT+0600 (Bangladesh Standard Time))
[BaseDriver] Number capability passed in as string. Functionality may be compromised.
[Appium]
[Appium] ======================================================================
[Appium] DEPRECATION WARNING:
[Appium]
[Appium] The 'automationName' capability was not provided in the desired
[Appium] capabilities for this Android session
[Appium]
[Appium] Setting 'automationName=UiAutomator2' by default and using the
[Appium] UiAutomator2 Driver
[Appium]
[Appium] The next major version of Appium (2.x) will **require** the
[Appium] 'automationName' capability to be set for all sessions on all
[Appium] platforms
[Appium]
[Appium] In previous versions (Appium <= 1.13.x), the default was
[Appium] 'automationName=UiAutomator1'
[Appium]
[Appium] If you wish to use that automation instead of UiAutomator2, please
[Appium] add 'automationName=UiAutomator1' to your desired capabilities
[Appium]
[Appium] For more information about drivers, please visit
[Appium] http://appium.io/docs/en/about-appium/intro/ and explore the
[Appium] 'Drivers' menu
[Appium]
[Appium] ======================================================================
[Appium]
[Appium] Appium v1.18.3 creating new AndroidUiautomator2Driver (v1.56.1) session
[Appium] Applying relaxed security to 'AndroidUiautomator2Driver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
[BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[BaseDriver] Creating session with W3C capabilities: {
[BaseDriver] "alwaysMatch": {
[BaseDriver] "platformName": "android",
[BaseDriver] "appium:app": "D:\\Automation Project\\Resources\\KandareeLiteApp\\src\\test\\resources\\KandareeLiteApp.apk",
[BaseDriver] "appium:appActivity": "bd.com.cslsoft.kandareeliteapp.view.activities.LauncherActivity",
[BaseDriver] "appium:appPackage": "bd.com.cslsoft.kandareeliteapp",
[BaseDriver] "appium:deviceName": "emulator-5554",
[BaseDriver] "appium:newCommandTimeout": "100"
[BaseDriver] },
[BaseDriver] "firstMatch": [
[BaseDriver] {}
[BaseDriver] ]
[BaseDriver] }
[BaseDriver] Number capability passed in as string. Functionality may be compromised.
[BaseDriver] Capability 'newCommandTimeout' changed from string ('100') to integer (100). This may cause unexpected behavior
[BaseDriver] Session created with session id: 9ff2777d-7fcd-4a7e-8e9d-02b3eed680f0
[BaseDriver] Using local app 'D:\Automation Project\Resources\KandareeLiteApp\src\test\resources\KandareeLiteApp.apk'
[UiAutomator2] Checking whether app is actually present
[ADB] Using 'adb.exe' from 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe'
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 start-server'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices
[ADB] Connected devices: [{"udid":"emulator-5554","state":"device"}]
[AndroidDriver] Using device: emulator-5554
[ADB] Using 'adb.exe' from 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe'
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 start-server'
[ADB] Setting device id to emulator-5554
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 29
[ADB] Getting device platform version
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 10
[ADB] Device API level: 29
[UiAutomator2] Relaxing hidden api policy
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell 'settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1''
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 wait-for-device'
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('3.2.0' >= '3.2.0')
[ADB] There is no need to install/upgrade 'D:\New folder\Appium-windows-1.18.3\resources\app\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[ADB] Getting IDs of all 'io.appium.settings' processes
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell 'pgrep --help; echo $?''
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell pgrep -f io\\.appium\\.settings'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[Logcat] Starting logs capture with command: C:\\Users\\syedyunus\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s emulator-5554 logcat -v threadtime
[UiAutomator2] Deleting UiAutomator2 session
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell am force-stop bd.com.cslsoft.kandareeliteapp'
[Logcat] Stopping logcat capture
[UiAutomator2] Restoring hidden api policy to the device default configuration
[ADB] Running 'C:\Users\syedyunus\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy''
[BaseDriver] Event 'newSessionStarted' logged at 1606228129127 (20:28:49 GMT+0600 (Bangladesh Standard Time))
[W3C] Encountered internal error running command: Error: Could not acquire lock on C:\Users\SYEDYU~1\AppData\Local\Temp\uia2_device_port_guard. Original error: Error: EEXIST: file already exists, open 'C:\Users\SYEDYU~1\AppData\Local\Temp\uia2_device_port_guard'
[W3C] at guard (D:\New folder\Appium-windows- 1.18.3\resources\app\node_modules\appium\node_modules\appium-support\lib\util.js:477:13)
[W3C] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 121825 ms - 1023
You can Manually delete the file uia2_device_port_guard from given location, Then run.
It worked for me as well.
Go to: C:\Users\(username)\AppData\Local\Temp\
Find: uia2_device_port_guard file
Delete it
Restart Appium server
Please delete the uia2_device_port_guard file it will work normally.
If you don't know the path then follow steps as below,
Open run window(Ctrl+R)
Type temp and click on OK
Select all and clear all the temps files.
Again write %temp% in open field and click on OK
Select all and clear all the temps files
uia2_device_port_guard file will delete automatically
After deleting the both the temp files, refresh and reopen. It will work fine.
As i did exactly the same and it started working normally.
For Mac users:
Open Terminal
Go to /var/folders/92/hbvgxyp96p3f5vxzgsf1thh80000gp/T
Delete file uia2_device_port_guard
Command:
rm uia2_device_port_guard

Appium - Timing out and Never got a response from command

We have UI tests to be started by Jenkins using Appium, but it results with an error:
remote stacktrace: UnknownError: An unknown server-side error occurred
while processing the command. Original error: Error getting AVD with
retry. Original error: Condition unmet after 60063 ms. Timing out.
And there is no emulator process found when Appium's task is running.
Also Appium's output says:
[debug] [ADB] Emulator Nexus_5X_API_26 not running
[debug] [ADB] Trying to find Nexus_5X_API_26 emulator
[debug] [ADB] Getting connected emulators
[debug] [ADB] Getting connected devices...
[debug] [ADB] 0 device(s) connected
[debug] [ADB] 0 emulator(s) connected
OK, I see that device wasn't started and this is cause for the "Timeout" error.
But why Appium can't start it?
I'm able to get the emulator executable, and Jenkin's job which is starting Appium's task can see the device:
[Pipeline] sh
+ avdmanager list avd
...
Name: Nexus_5X_API_26
Device: Nexus 5X (Google)
Path: /home/user/.android/avd/Nexus_5X_API_26.avd
Target: Google Play (Google Inc.)
Based on: Android 8.0 (Oreo) Tag/ABI: google_apis_playstore/x86
Skin: 1080x1920
Sdcard: 100 MB
---------
Name: test
Path: /home/user/.android/avd/test.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
[Pipeline] sh
+ emulator -list-avds
Nexus_5X_API_26
test
If I'm starting device manually just by running:
/android/Android/sdk/emulator/emulator -avd Nexus_5X_API_26
And trigger Jenkin's job after this - I have another error:
...
[ADB] Using adb from /android/Android/sdk/platform-tools/adb
[debug] [ADB] Trying to find Nexus_5X_API_26 emulator
[debug] [ADB] Getting connected emulators
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] 1 emulator(s) connected
[debug] [ADB] Sending telnet command to device: avd name
[debug] [ADB] Getting running emulator port
[debug] [ADB] Socket connection to device created
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1542807589908 (15:39:49 GMT+0200 (EET))
[debug] [W3C] Encountered internal error running command: Error: Error getting AVD. Original error: Never got a response from command
[debug] [W3C] at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:488:11)
...
Any ideas?
Can't even google anything with the "appium Never got a response from command" request...
Also, I'm not able to reproduce this issue on my workstation's laptop - all works just perfectly.
UPD Properties are:
<profile>
<id>linux-emulator-8.0</id>
<properties>
<hub.url>http://0.0.0.0:4723/wd/hub</hub.url>
<device.name>Android Emulator</device.name>
<avd>Nexus_5X_API_26</avd>
<platform.name>Android</platform.name>
<platform.version>8.0</platform.version>
<auto.grant.permissions>true</auto.grant.permissions>
<full.reset>true</full.reset>
<no.reset>false</no.reset>
<app.path>/home/user/project/project.apk</app.path>
<app.name>com.gen.workoutme</app.name>
<screenshot.path>
${project.basedir}/../screenShots/${platform.name}/${platform.version}/${device.name}/
</screenshot.path>
<automation.name>UiAutomator2</automation.name>
</properties>
</profile>
UPD 2 Not sure how - but not it works if run emulator manually.
But still, there is a problem with starting the emulator from Appium itself.
Found the weird error in its log:
[ADB] [AVD OUTPUT] Fatal: QXcbConnection: Could not connect to display ((null):0, (null))
[ADB] [AVD OUTPUT] INFO: QtLogger.cpp:66: Fatal: QXcbConnection: Could not connect to display ((null):0, (null))
[ADB] Emulator avd Nexus_5X_API_26 exited with code null, signal SIGABRT
Can't google for reason yet but it looks like the main issue - something with a connection to the $DISPLAY, although it present.
I am able to start and run tests on emulator without any problem. I use following three capabilities along with other capabilities while setting up the driver.
avd: Name of AVD
avdLaunchTimeout: Time out to wait for emulator to launch.
avdReadyTimeout: Time out to wait for emulator to get ready.
Try using these capabilities and you should be good.
Also check if there is any updates for Android SDK and emulator. If there is update available, it's good idea to update it.
Settings or python:
options = UiAutomator2Options()
options.avd = 'YOUR_AVD_NAME'
# Timeout to wait until Android Emulator is started in milliseconds
options.avd_launch_timeout = 25 * 1000
# Timeout to wait until Android Emulator is fully booted and is ready for usage in milliseconds
options.avd_ready_timeout = 20 * 1000
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', options=options)

Appium desktop server error when starting session could not sign with default certificate

I cannot start a new session on my Appium desktop server. I haven't found any fix that works for me. This is my error message:
Encountered internal error running command: Error: Could not sign with
default certificate. Original error Command ''C:\\Program
Files\\Java\\jdk1.8.0_181\\bin\\java.exe' -jar 'C:\\Program Files
(x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-
adb\\jars\\sign.jar' 'C:\\Program Files
(x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-
uiautomator2-server\\apks\\appium-uiautomator2-server-v1.12.0.apk' --
override' exited with code 1
Logs:
[Appium] Creating new AndroidUiautomator2Driver (v1.12.0) session
[Appium] Capabilities:
[Appium] app: "myapp/path/"
[Appium] appActivity: mydeviceActivity
[Appium] appPackage: base.apk
[Appium] automationName: UiAutomator2
[Appium] deviceName: OPPO F1s
[Appium] platformName: Android
[Appium] platformVersion: 5.1
[Appium] newCommandTimeout: 0
[Appium] connectHardwareKeyboard: true
[BaseDriver] Creating session with MJSONWP desired capabilities: {"app":"https://drive.googl...
[BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
[BaseDriver] Session created with session id: a231071d-b167-42f3-9c4c-ffecc32e9076
............
[BaseDriver] Skipping 'https://drive.google..........' caching, because the HEAD response didn't return any valid Last-Modified headers
[UiAutomator2] Checking whether app is actually present
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_181
[ADB] Checking whether adb is present
[ADB] Found 1 'build-tools' folders under 'C:\Program Files\Android\SDK' (newest first):
[ADB] C:/Program Files/Android/SDK/build-tools/28.0.2
[ADB] Using adb.exe from C:\Program Files\Android\SDK\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '5.1'
[ADB] Setting device id to SOVW6PUS99999999
[ADB] Getting device platform........................................
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 shell am force-stop io.appium.uiautomator2.server'
[ADB] Checking app cert for C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk
[ADB] Using apksigner.bat from C:\Program Files\Android\SDK\build-tools\28.0.2\apksigner.bat
[ADB] Starting 'C:\Program Files\Android\SDK\build-tools\28.0.2\apksigner.bat' with args 'verify,--print-certs,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk'
[ADB] 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk' is not signed with debug cert.
[ADB] Zip-aligning 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk'
[ADB] Checking whether zipalign is present
[ADB] Using zipalign.exe from C:\Program Files\Android\SDK\build-tools\28.0.2\zipalign.exe
[ADB] Signing 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk' with default cert
[ADB] Starting 'C:\Program Files\Android\SDK\build-tools\28.0.2\apksigner.bat' with args 'sign,--key,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-adb\keys\testkey.pk8,--cert,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-adb\keys\testkey.x509.pem,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk'
[ADB] Cannot use apksigner tool for signing. Defaulting to sign.jar. Original error: Command ''C:\\Program Files\\Android\\SDK\\build-tools\\28.0.2\\apksigner.bat' sign --key 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.pk8' --cert 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.x509.pem' 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v1.12.0.apk'' exited with code 1; StdErr: 'C:\Program' is not recognized as an internal or external command,
[ADB] operable program or batch file.
[ADB]
[ADB] Resigning apk.
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 shell am force-stop base.apk'
[ADB] Removing forwarded port socket connection: 8200
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 forward --remove tcp\:8200'
[ADB] Running 'C:\Program Files\Android\SDK\platform-tools\adb.exe -P 5037 -s SOVW6PUS99999999 forward --remove tcp\:8200'
[UiAutomator2] Unable to remove port forward 'Error executing adbExec. Original error: 'Command ''C:\\Program Files\\Android\\SDK\\platform-tools\\adb.exe' -P 5037 -s SOVW6PUS99999999 forward --remove tcp\:8200' exited with code 1'; Stderr: 'error: listener 'tcp:8200' not found'; Code: '1''
[BaseDriver] Event 'newSessionStarted' logged at 1534424157559 (19:55:57 GMT+0700 (SE Asia Standard Time))
[MJSONWP] Encountered internal error running command: Error: Could not sign with default certificate. Original error Command ''C:\\Program Files\\Java\\jdk1.8.0_181\\bin\\java.exe' -jar 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\jars\\sign.jar' 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v1.12.0.apk' --override' exited with code 1
EDIT, SOLVED:
Thanks to Ross I've found out where the problem is.
I've solved it by changing the path of ANDROID_HOME and JAVA_HOME from C:\Program Files\ to C:\PROGRA~1\ like it said here.
Just run appium as admin and your problem will be solved. I have also been facing the same problem. I have searched and come to know that no need to change the path variables address.
Follow these steps:
Run appium as admin.
Before starting server, click options Advanced and checkbox mark Allow Session Override.
This problem can be resolved, by properly setting desiredCapabilities. Generally we specify automationName as uiautomator2. The moment we right this error is thrown.
Exact desiredCapability would be like this, "automatorName" text "UiAutomator2"
there is another property which is used to skip the signing process in appium desktop.
"noSign" "true"
use these two desiredCapabilities together it will work fine.

Unable to launch ipa file in IOS 10 real Device using appium 1.6.0

To start with I got a .ipa file from the development team to test, the developer has mentioned the .ipa file with the device UDID so that I can install it on my iPhone.
[Appium] Welcome to Appium v1.6.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"/Users/apple/Downloads/ReaderManager.ipa","noReset":true,"platformVersion":"10.0","bundleId":"com.hidglobal.pacs.se.readermanager","platformName":"iOS","udid":"1f51471daf2a4674f11ece1a19d6cb4fa5569c02","deviceName":"iPhone 6"},"requiredCapabilities":{}},"desiredCapabilities":{"app":"/Users/apple/Downloads/ReaderManager.ipa","noReset":true,"platformVersion":"10.0","bundleId":"com.hidglobal.pacs.se.readermanager","platformName":"iOS","udid":"1f51471daf2a4674f11ece1a19d6cb4fa5569c02","deviceName":"iPhone 6"},"requiredCapabilities":{}}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id"]} and you sent ["capabilities","desiredCapabilities","requiredCapabilities"]
[HTTP] <-- POST /wd/hub/session 400 6 ms - 201
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/apple/Downloads/ReaderManager.ipa","noReset":true,"platformVersion":"10.0","bundleId":"com.hidglobal.pacs.se.readermanager","platformName":"iOS","udid":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","deviceName":"iPhone 6"},"requiredCapabilities":{}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/apple/Downl...
[Appium] Requested iOS support with version >= 10, using XCUITest driver instead of UIAutomation-based driver, since the latter is unsupported on iOS 10 and up.
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] app: '/Users/apple/Downloads/xyz.ipa'
[Appium] noReset: true
[Appium] platformVersion: '10.0'
[Appium] bundleId: 'xxxxxxxx'(Changed Manually)
[Appium] platformName: 'iOS'
[Appium] udid: 'xxxxxxxxxxxxxxxxxxxxx'(Changed Manually)
[Appium] deviceName: 'iPhone 6'
[debug] [XCUITest] XCUITestDriver version: 2.0.26
[BaseDriver] Session created with session id: f1a2a222-8e4f-47fb-bbbd-2429f159b403
[debug] [XCUITest] Xcode version set to '8.0'
[debug] [XCUITest] iOS SDK Version set to '10.0'
[debug] [XCUITest] Available devices: xxxxxxxxxxxxxx
[debug] [XCUITest] Creating iDevice object with udid xxxxxxxxxxxxxxxxxxx
[XCUITest] Determining device to run tests on: udid: 'xxxxxxxxxxxxxxxxx', real device: true
[BaseDriver] Using local app '/Users/apple/Downloads/ReaderManager.ipa'
[debug] [BaseDriver] Copying local zip to tmp dir
[debug] [BaseDriver] Unzipping /var/folders/2d/qg1847_14nd90zgq9_m30zhc0000gn/T/2016926-3576-bfkmhz.8l1yycik9/appium-app.zip
[debug] [BaseDriver] Testing zip archive: /var/folders/2d/qg1847_14nd90zgq9_m30zhc0000gn/T/2016926-3576-bfkmhz.8l1yycik9/appium-app.zip
[BaseDriver] Unzipped local app to '/var/folders/2d/qg1847_14nd90zgq9_m30zhc0000gn/T/2016926-3576-bfkmhz.8l1yycik9/Payload/ReaderManager.app'
[debug] [XCUITest] Checking whether app is actually present
[debug] [iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog
[debug] [iOSLog] Found idevicesyslog: '/usr/local/bin/idevicesyslog'
[XCUITest] Setting up real device
[debug] [XCUITest] Stdout from app isInstalled check: [....] Waiting for iOS device to be connected
[....] Using iPhone 6 (GSM) 'Iphone 6' (xxxxxxxxxxxxxxx).
true
[debug] [XCUITest] App is installed.
[debug] [XCUITest] Full reset not requested. No need to install.
[XCUITest] Using default agent: /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj
[XCUITest] Using default bootstrap: /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
[XCUITest] Launching WebDriverAgent on the device
[debug] [XCUITest] Carthage found: /usr/local/bin/carthage
[debug] [XCUITest] Beginning test with command '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/bin/run-xcodebuild.sh --project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj --scheme WebDriverAgentRunner --destination id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' in directory '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Waiting for WebDriverAgent to start on device
[XCUITest] The real device logger 'idevicesyslog' was unable to start log capture. Please try installing 'deviceconsole' ('npm install -g deviceconsole') and specify the path to it using the 'realDeviceLogger' capability.
[debug] [XCUITest] Log file for xcodebuild test: /Users/apple/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Logs/Test/5D3AF14D-B012-422A-B281-1F3CE59A49EA/Session-WebDriverAgentRunner-2016-10-26_150854-8VLGgF.log
[Xcode] 2016-10-26 15:08:58.437 xcodebuild[3594:21573] Error Domain=IDETestOperationsObserverErrorDomain Code=3 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/apple/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Logs/Test/5D3AF14D-B012-422A-B281-1F3CE59A49EA/Session-WebDriverAgentRunner-2016-10-26_150854-8VLGgF.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/apple/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Logs/Test/5D3AF14D-B012-422A-B281-1F3CE59A49EA/Session-WebDriverAgentRunner-2016-10-26_150854-8VLGgF.log}
[Xcode] Code signing is required for product type 'UI Testing Bundle' in SDK 'iOS 10.0'
[Xcode] Signing for "WebDriverAgentRunner" requires a development team. Select a development team in the project editor.enter code here
[Xcode] Code signing is required for product type 'UI Testing Bundle' in SDK 'iOS 10.0'
During my execution of script I am getting the above issue.
Request the team to help me in identifying the issue and how to resolve it.
Thanks,
Goutham
Run the below command in terminal to open WebDriverAgent project.
Open usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj
Now this will open the WebDriverAgent project in xcode.
Go to build settings of the project as shown in below screenshot and add the development team.
If no options are available in development team to select then follow the below procedure to add the account.
a. Click on xcode and navigate to preferences.
b. Click on Accounts.
c. Click on ‘+’ symbol and add the account same as the account used for the code signing activity.
Now you can select the added account in Development Team.
The account selected for the development team should be same as the account selected for code signing activity.
Now add development team for all the targets also similarly by navigating to build settings.
Run the code to check for any errors and build succeeded message should be displayed.
Please refer Bluedev comment as well.
if you are unable to execute appium script even after creating a developer team and building the app in Xcode..
Follow the steps given in the below link and try running appium after those steps, I tried it (note: there were some unthinkable libraries missing installation:) and working for me. I am having Mac OS 10.12.5 and Appium version 1.6.5. Hope this is helpful.
Appium Setup for running on real and emulated devices

Could not pre-launch appium and app doesn't get installed in iphone real device using appium

I am using appium version 1.3.7.
I have connected physical device via usb.
I have launched appium server,after a while appium get crashed.
I have pasted that full log below.
I have attached the screen shot below.
Launching Appium with command: '/Applications/Appium.app/Contents/Resources/node/bin/node' lib/server/main.js --command-timeout "7200" --pre-launch --platform-version "8.1" --platform-name "iOS" --app "/Users/al/work/sample.app" --udid "f5de3fd5ccded92e40e86c652ce2a6f9414fe1a0" --device-name "iPhone 4s"
info: [debug] Starting Appium in pre-launch mode
info: Pre-launching app
info: [debug] Using local app from command line: /Users//al/work/sample.app
info: [debug] Creating new appium session 1cdc5dc0-36d2-40b9-922b-33601f28846b
info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Setting Xcode folder
info: [debug] Setting Xcode version
info: [debug] Setting iOS SDK Version
info: [debug] Getting sdk version from xcrun with a timeout
info: [debug] iOS SDK Version set to 8.1
info: [debug] Not checking whether simulator is available since we're on a real device
info: [debug] Detecting automation tracetemplate
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: On some xcode 6 platforms, instruments-without-delay does not work. If you experience this, you will need to re-run appium with the --native-instruments-lib flag
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/alk/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/alk/Library/Application Support/appium/bootstrap/bootstrap-d5a0fb924946d8d3.js
info: [debug] Reusing dynamic bootstrap: /Users/alk/Library/Application Support/appium/bootstrap/bootstrap-d5a0fb924946d8d3.js
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.1.1","iOSSDKVersion":"8.1","deviceName":"iPhone 4s","platformVersion":"8.1"}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 4s (8.1 Simulator)'
info: [debug] Not setting device type since we're on a real device
info: [debug] Checking whether we need to set app preferences
info: [debug] Not setting iOS and app preferences since we're on a real device
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator
info: [debug] Killing any other simulator daemons
info: [debug] On a real device; cannot clean device state
info: [debug] Not setting locale because we're using a real device
info: [debug] No iOS / app preferences to set
info: [debug] Starting iOS device log capture via deviceconsole
info: [debug] Not pre-launching simulator
info: [debug] Creating iDevice object with udid f5de3fd5ccded92e40e86c652ce2a6f9414ee1a2
info: [debug] Checking app install status using: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id f5de3fd5ccded92e40e86c652ce2a6f9414ee1a2 --bundle com.vr.iphone.sample
info: [debug] App is not installed. Will try to install the app.
info: [debug] Installing app using cmd: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id f5de3fd5ccded92e40e86c652ce2a6f9414ee1a2 --bundle "/Users/al/work/sample.app
info: [debug] Cleaning up appium session
error: Could not pre-launch appium: Error: Unable to install [/Users/al/work/sample.app] to device with id [f5de3fd5ccded92e40e86c652ce2a6f9414ee1a2]. Error [Error: Command failed: /bin/sh -c /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id f5de3fd5ccded92e40e86c652ce2a6f9414ee1a2 --bundle "/Users/al/work/sample.app"
Assertion failed: (AMDeviceStartService(device, CFSTR("com.apple.afc"), &afcFd, NULL) == 0), function handle_device, file fruitstrap.c, line 523.
]
You can use Appium to install your app on your device, Just uninstall your App manually and in setUp code use absolute path of .apk file like this:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("VERSION", "5.1.1");
capabilities.setCapability("deviceName", "Name");
File appDir = new File("/home/filename/ProjectFile");
File app = new File(appDir, "appname.apk");
capabilities.setCapability("app",app.getAbsolutePath());
It will install your app on your device.
You said you tried to launch on real device, but your logs saying you tried to launch on simulator.
If you are using UI version of appium, Please uncheck Force Device option in appium and give UDID of real device which you connected in appium and prelaunch. your app will be installed.

Resources