Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 688
illmaster Avatar asked Dec 23 '22 04:12

illmaster


2 Answers

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:

  1. Run appium as admin.
  2. Before starting server, click options Advanced and checkbox mark Allow Session Override.
like image 115
Wasim Nawaz Avatar answered May 03 '23 10:05

Wasim Nawaz


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.

like image 24
Hardik Rathod Avatar answered May 03 '23 11:05

Hardik Rathod