1
votes

An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate. Original error spawn ENOTDIR

I am trying to start an android app using Appium Desktop app. Appium server shows the following error log;

Starting '/home/santoshpc/Android/Sdk/build-tools/28.0.3/apksigner' with args '["sign","--key","/tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.pk8","--cert","/tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.x509.pem","/tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk"]' [ADB] Got an error during apksigner execution: Command '/home/santoshpc/Android/Sdk/build-tools/28.0.3/apksigner sign --key /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.pk8 --cert /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.x509.pem /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk' exited with code 1 [ADB] apksigner stderr: Exception in thread "main" java.nio.file.FileSystemException: /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk: Read-only file system [ADB] at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) [ADB] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) [ADB] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) [ADB] at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:447) [ADB] at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262) [ADB] at java.nio.file.Files.move(Files.java:1395) [ADB] at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:342) [ADB] at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:89) [ADB] [ADB] Cannot use apksigner tool for signing. Defaulting to sign.jar. Original error: Command '/home/santoshpc/Android/Sdk/build-tools/28.0.3/apksigner sign --key /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.pk8 --cert /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.x509.pem /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk' exited with code 1; StdErr: Exception in thread "main" java.nio.file.FileSystemException: /tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk: Read-only file system [ADB] at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) [ADB] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) [ADB] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) [ADB] at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:447) [ADB] at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262) [ADB] at java.nio.file.Files.move(Files.java:1395) [ADB] at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:342) [ADB] at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:89) [ADB] [ADB] Resigning apk. [UiAutomator2] Deleting UiAutomator2 session [UiAutomator2] Deleting UiAutomator2 server session [WD Proxy] Matched '/' to command name 'deleteSession' [UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id [ADB] Running '/home/santoshpc/Android/Sdk/platform-tools/adb -P 5037 -s 0123456789ABCDEF shell am force-stop eu.niko.smart.naswi.main' [Logcat] Stopping logcat capture [ADB] Removing forwarded port socket connection: 8200 [ADB] Running '/home/santoshpc/Android/Sdk/platform-tools/adb -P 5037 -s 0123456789ABCDEF forward --remove tcp:8200' [UiAutomator2] Unable to remove port forward 'Error executing adbExec. Original error: 'Command '/home/santoshpc/Android/Sdk/platform-tools/adb -P 5037 -s 0123456789ABCDEF forward --remove tcp:8200' exited with code 1'; Stderr: 'error: listener 'tcp:8200' not found'; Code: '1'' [BaseDriver] Event 'newSessionStarted' logged at 1552282079530 (11:12:59 GMT+0545 (+0545)) [MJSONWP] Encountered internal error running command: Error: Could not sign with default certificate. Original error spawn ENOTDIR [MJSONWP] at ADB.apkSigningMethods.signWithDefaultCert (/tmp/.mount_AppiumGDrtg1/resources/app/node_modules/appium/node_modules/appium-adb/lib/tools/apk-signing.js:124:13) [HTTP] <-- POST /wd/hub/session 500 9847 ms - 206 [HTTP] [HTTP] --> DELETE /wd/hub/session [HTTP] {} [HTTP] No route found. Setting content type to 'text/plain' [HTTP] <-- DELETE /wd/hub/session 404 5 ms - 57

I have added following DesiredCapabilities

{
  "noReset": true,
  "automationName": "uiautomator2",
  "appPackage": "myapp package name",
  "appActivity": "my app activity name",
  "deviceName": "My device",
  "platformName": "android"
}

Appium Desktop version: 1.11.1 OS - ubuntu

2

2 Answers

0
votes

This is a bug in the "apk-signing.js" file residing in location /usr/lib/node_modules/appium/node_modules/appium-adb/build/lib/tools.

Possible Solutions:

  1. It can be permission issue. The appium is executed without root privilege so it cannot make the changes to the apk. Executing appium with root/admin privilege solves the problem. (works only if apk-signing.js is bug free)
  2. It's working fine for specific appium's versions as they don't have bug free apk-signing.js like appium version 1.7.2.

This is final solution if above 2 will not work. You have to modify the file apk-signing.js

./node-v6.11.4-linux-armv7l/lib/node_modules/appium/node_modules/appium-adb/build/lib/tools/apk-signing.js

so it would return a true even if it looks not signed. Edit file as mentioned below.

287 case 20:
288 context$1$0.prev = 20;
289 context$1$0.t0 = context$1$0’catch’;
290
291 _loggerJs2[‘default’].debug(“App not signed with debug cert.”);
292 return context$1$0.abrupt(‘return’, true);

Please check this link for editing the file and for more details.

https://discuss.appium.io/t/appium-1-7-1-canot-singin-appium-uiautomator2-server-debug-androidtest-apk/19233/4

Hope it will help.

0
votes

For me what worked is going to Appium Desktop configurations and changing the JAVA_HOME from

/usr/java/bin

to

/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home