appium icon indicating copy to clipboard operation
appium copied to clipboard

[Android] Cannot start test with v1.9.0, Error when unzipping AndroidManifest.xml.apk

Open lamquangthanh opened this issue 8 years ago • 25 comments

The problem

I cannot start test with new version of appium. Error when unzipping AndroidManifest.xml.apk "automationName": "Espresso", "platformName": "Android",

Environment

  • Appium version (or git revision) that exhibits the issue: 1.9.0
  • Last Appium version that did not exhibit the issue (if applicable):1.8.1
  • Desktop OS/version used to run Appium: Win 10
  • Node.js version (unless using Appium.app|exe): 6.1.0
  • Mobile platform/version under test: Android 7
  • Real device or emulator/simulator: Nexus 6 real devices
  • Appium CLI or Appium.app|exe: Appium CLI

Log of Eclipse

Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error occurred while unzipping. Original error: Zip archive does not exist at 'C:\Users\Ekino\AppData\Local\Temp\AndroidManifest.xml.apk' (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13.25 seconds
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'EVN-D-W-0017', ip: '10.161.206.82', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: AppiumAndroidDriver
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
	at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
	at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
	at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:122)
	at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
	at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
	at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
	at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
	at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)

## Link to Appium logs

-s ZX1G227NJC shell ps'
[debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell settings get global animator_duration_scale'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell settings get global transition_animation_scale'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell settings get global window_animation_scale'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell am broadcast -a io.appium.settings.animation -n io.appium.settings/.receivers.AnimationSettingReceiver --es setstatus disable'
[ADB] Getting device platform version
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell getprop ro.build.version.release'
[debug] [ADB] Current device property 'ro.build.version.release': 7.0
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell wm size'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell getprop ro.product.model'
[debug] [ADB] Current device property 'ro.product.model': Nexus 6
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell getprop ro.product.manufacturer'
[debug] [ADB] Current device property 'ro.product.manufacturer': motorola
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC wait-for-device'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell echo ping'
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell pm list packages io.appium.settings'
[debug] [ADB] App is installed
[debug] [ADB] Getting package info for 'io.appium.settings'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell dumpsys package io.appium.settings'
[debug] [ADB] The installed 'io.appium.settings' package does not require upgrade ('2.3.0' >= '2.3.0')
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell ps'
[debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 24
[debug] [ADB] Device API level: 24
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell appops set io.appium.settings android\:mock_location allow'
[debug] [ADB] Device API level: 24
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell getprop persist.sys.locale'
[debug] [ADB] Current device property 'persist.sys.locale': en-UK
[debug] [ADB] Current locale: 'en-UK'; requested locale: 'en-UK'
[debug] [ADB] Device API level: 24
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell getprop persist.sys.locale'
[debug] [ADB] Current device property 'persist.sys.locale': en-UK
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Getting install status for io.appium.unlock
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell pm list packages io.appium.unlock'
[debug] [ADB] App is installed
[debug] [ADB] Getting package info for 'io.appium.unlock'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell dumpsys package io.appium.unlock'
[debug] [ADB] The installed 'io.appium.unlock' package does not require upgrade ('2.0.0' >= '2.0.0')
[debug] [Espresso] Forwarding Espresso Server port 8080 to 8080
[debug] [ADB] Forwarding system: 8080 to device: 8080
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC forward tcp\:8080 tcp\:8080'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [Espresso] No app capability. Assuming it is already on the device
[debug] [ADB] Checking app cert for null
[debug] [ADB] 'null' doesn't exist
[Espresso] Repackaging espresso server for: 'com.accor.appli.hybrid'
[Espresso] Creating new manifest: 'C:\Users\Ekino\AppData\Local\Temp\AndroidManifest.xml'
[debug] [ADB] Compiling manifest C:\Users\Ekino\AppData\Local\Temp\AndroidManifest.xml
[debug] [ADB] Found the most recent Android platform: {"platform":"android-P","platformPath":"D:/android-sdk_r24.4.1-windows/android-sdk-windows/platforms/android-P"}
[debug] [ADB] Compiling manifest.
[debug] [ADB] Compiled manifest
[debug] [ADB] Inserting manifest, src: C:\Users\Ekino\AppData\Roaming\npm\node_modules\appium\node_modules\appium-espresso-driver\espresso-server\app\build\outputs\apk\androidTest\debug\app-debug-androidTest.apk dst: C:\Users\Ekino\AppData\Local\Temp\io.appium.espressoserver.test_1.0.0-beta.13_com.accor.appli.hybrid.apk
[debug] [ADB] Unzipping C:\Users\Ekino\AppData\Local\Temp\AndroidManifest.xml.apk
[debug] [ADB] Testing zip archive: 'C:\Users\Ekino\AppData\Local\Temp\AndroidManifest.xml.apk'
[debug] [Espresso] Deleting espresso session
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell am broadcast -a io.appium.settings.animation -n io.appium.settings/.receivers.AnimationSettingReceiver --es setstatus enable'
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC shell am force-stop com.accor.appli.hybrid'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8080
[debug] [ADB] Running 'D:\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s ZX1G227NJC forward --remove tcp\:8080'
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1535439399941 (13:56:39 GMT+0700 (SE Asia Standard Time))
[MJSONWP] Encountered internal error running command: Error: Error occurred while unzipping. Original error: Zip archive does not exist at 'C:\Users\Ekino\AppData\Local\Temp\AndroidManifest.xml.apk'
[MJSONWP]     at unzipFile$ (C:\Users\Ekino\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\helpers.js:76:11)
[MJSONWP]     at tryCatch (C:\Users\Ekino\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[MJSONWP]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Ekino\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[MJSONWP]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Ekino\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[MJSONWP]     at GeneratorFunctionPrototype.invoke (C:\Users\Ekino\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session 500 13191 ms - 280
[HTTP]

lamquangthanh avatar Aug 28 '18 07:08 lamquangthanh

It seems like aapt fails to compile the manifest on your machine. Try to execute it manually from the command line and check what the actual output is. The command compilation algorithm itself can be taken from https://github.com/appium/appium-adb/blob/122af37a5be16bccc86c6a0f3fcfa11cfc23d7ac/lib/tools/android-manifest.js#L250

mykola-mokhnach avatar Aug 28 '18 09:08 mykola-mokhnach

@mykola-mokhnach I see the log of appium and check the location of file. (See attachment http://prntscr.com/kns6um ). Have 2 file:

AndroidManifest.xml.apk and

io.appium.espressoserver.test_1.0.0-beta.13_com.accor.appli.hybrid.apk But adb fail to open it.

lamquangthanh avatar Aug 28 '18 11:08 lamquangthanh

It might be the file is locked by some antivirus software

mykola-mokhnach avatar Aug 28 '18 11:08 mykola-mokhnach

or the appium server user has no permissions in that folder

mykola-mokhnach avatar Aug 28 '18 11:08 mykola-mokhnach

@mykola-mokhnach how to give permission for that folder, i try to delete this file but not have permission.

lamquangthanh avatar Aug 28 '18 11:08 lamquangthanh

when I stop appium, file io.appium.espressoserver.test_1.0.0-beta.13_com.accor.appli.hybrid.apk is disappear. When dont stop appium, dont have permission to delete this file.

lamquangthanh avatar Aug 28 '18 11:08 lamquangthanh

I try to change "automationName": "Espresso" to "automationName": "uiautomator2". I also cannot start test with v1.9.0. I have error "An unknown server-side error occurred while processing the command. Original error: The desired capabilities must include either 'appPackage' or 'browserName'" But already have 2 these options in capabilities. And 2 capabilities work fine with v1.8.1 Until i upgrade to v1.9.0, I cannot start test to run.

lamquangthanh avatar Aug 28 '18 11:08 lamquangthanh

The error there is correct. You must fix the capabilities.

mykola-mokhnach avatar Aug 28 '18 11:08 mykola-mokhnach

"browserName": "android", "appPackage": "com.accor.appli.hybrid", The 2 options in my capabilities.

lamquangthanh avatar Aug 28 '18 12:08 lamquangthanh

http://appium.io/docs/en/writing-running-appium/caps/

browserName Name of mobile web browser to automate. Should be an empty string if automating an app instead.


you can see an example capabilities of android test in http://appium.io/docs/en/about-appium/getting-started/

KazuCocoa avatar Aug 28 '18 13:08 KazuCocoa

@lamquangthanh @eMTe123 Try to apply the patch from https://github.com/appium/appium-adb/pull/348 to your local source and confirm if this fixes the problem, because I don't have Windows machine to test it

mykola-mokhnach avatar Aug 28 '18 14:08 mykola-mokhnach

@mykola-mokhnach I updated android-manifest.js and apk-signing.js. But dont have have test/unit/apk-signing-specs.js in my node_modules folder. If I use "automationName": "uiautomator2", and capabilities "browserName": "", ==>It works for me.

lamquangthanh avatar Aug 29 '18 04:08 lamquangthanh

The files must be updated inside /lib folder. After that it is necessary to run gulp transpile from module root. The last step would be to restart node. It is not necessary to replace anything inside /test as these files contain unit/integration tests and are not needed in production.

mykola-mokhnach avatar Aug 29 '18 05:08 mykola-mokhnach

@mykola-mokhnach still getting

ERROR: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate. Original error Command ''C:\Program Files\Java\jdk-10.0.1\bin\java.exe' -jar C:\repos\app-test\node_modules\appium\node_modules\appium-adb\jars\sign.jar C:\Users\user\AppData\Local\Temp\io.appium.espressoserver.test_1.0.0-beta.13_x.mobil.radio.apk --override' exited with code 1

I changed the files, did a npm install in the root folder in node_modules for appium-adb, and then a gulp transpile. Started a fresh appium server and ran my tests. Unlike @lamquangthanh I am running with "automationName":"Espresso". It has always, and still is working with "automationName":"uiautomator2" for me.

Full logs: https://gist.github.com/eMTe123/eba9ef5c76be5c9469a339bfb76ab7f0

eMTe123 avatar Aug 29 '18 08:08 eMTe123

@eMTe123 Can you check what needs to be done on your system in order to make the C\:\\Users\\username\\AppData\\Local\\Android\\Sdk\\build-tools\\28.0.2\\apksigner.bat sign --key C\:\\repos\\y-app-test\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.pk8 --cert C\:\\repos\\y-app-test\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.x509.pem C\:\\Users\\username\\AppData\\Local\\Temp\\io.appium.espressoserver.test_1.0.0-beta.13_x.mobil.y.apk command to work properly?

mykola-mokhnach avatar Aug 29 '18 09:08 mykola-mokhnach

@mykola-mokhnach the issue seems to be with the file io.appium.espressoserver.test_1.0.0-beta.13_x.mobil.y.apk

When I run the command it says

Exception in thread "main" java.io.FileNotFoundException: C:\Users\n639216\AppData\Local\Temp\io.appium.espressoserver.test_1.0.0-beta.13_no.nrk.mobil.radio.apk (no access)

Also this file is automatically deleted when I close the appium server. Which makes me unsure if it's my system that's preventing me from doing anything with the file (since I should have full access).

eMTe123 avatar Aug 29 '18 10:08 eMTe123

@eMTe123 You can actually see which applications are locking the file: https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows

Also, check the actual file NTFS permissions.

mykola-mokhnach avatar Aug 29 '18 14:08 mykola-mokhnach

@mykola-mokhnach The culprit is node.exe (Node.js: Server-side JavaScript), and won't allow me to do anything with the file, among other things I am not allowed to check NTFS permissions 😟

eMTe123 avatar Aug 30 '18 06:08 eMTe123

@eMTe123 does this mean your system account is the one with limited privileges?

mykola-mokhnach avatar Sep 06 '18 16:09 mykola-mokhnach

@mykola-mokhnach I have switched from Windows to Ubuntu now. Getting further but still having issues using the Espresso driver. Appium starts the app when I use inspector, but ends up with the following error:

[Espresso] Instrumentation process exited with code 0 from signal null [BaseDriver] Event 'newSessionStarted' logged at 1536737648474 (09:34:08 GMT+0200 (CEST)) [MJSONWP] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Throwable.toString()' on a null object reference [MJSONWP] at io.appium.espressoserver.lib.handlers.CreateSession.handle(CreateSession.java:38) [MJSONWP] at io.appium.espressoserver.lib.handlers.CreateSession.handle(CreateSession.java:27) [MJSONWP] at io.appium.espressoserver.lib.http.Router.route(Router.java:251) [MJSONWP] at io.appium.espressoserver.lib.http.Server.serve(Server.java:62) [MJSONWP] at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244) [MJSONWP] at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945) [MJSONWP] at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192) [MJSONWP] at java.lang.Thread.run(Thread.java:764) [MJSONWP] [MJSONWP] at errorFromMJSONWPStatusCode (/tmp/.mount_appium5hMkZk/app/resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:787:10) [MJSONWP] at ProxyRequestError.getActualError (/tmp/.mount_appium5hMkZk/app/resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:681:14) [MJSONWP] at JWProxy.command$ (/tmp/.mount_appium5hMkZk/app/resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:369:19) [MJSONWP] at tryCatch (/tmp/.mount_appium5hMkZk/app/resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) [MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (/tmp/.mount_appium5hMkZk/app/resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) [MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/tmp/.mount_appium5hMkZk/app/resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) [MJSONWP] at GeneratorFunctionPrototype.invoke (/tmp/.mount_appium5hMkZk/app/resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) [MJSONWP] at [HTTP] <-- POST /wd/hub/session 500 51423 ms - 834 [HTTP]

eMTe123 avatar Sep 12 '18 07:09 eMTe123