appium-espresso-driver icon indicating copy to clipboard operation
appium-espresso-driver copied to clipboard

Couldn't use .apks in appium espresso driver

Open skarindra opened this issue 4 years ago • 9 comments
trafficstars

Hi, I saw that in the Readme, we're allowed to use either .apk or .apks for the app capability, but when I tried to run the test using .apks, I got this error

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: A new session could not be created. Details: New app path '/Users/sakarindra/project/gitlab/marketplace-qa.apks' did not have extension: .apk

I'm using Appium 1.22.0.

Please advise, thank you!

skarindra avatar Nov 05 '21 09:11 skarindra

This doc is misleading. Espresso driver does not support files in .apks format. I've created a PR to actualize the README

mykola-mokhnach avatar Nov 05 '21 10:11 mykola-mokhnach

noted, thanks @mykola-mokhnach ! Is there any plan for improvement, maybe in the future, to support .apks or .aab for espresso driver?

skarindra avatar Nov 05 '21 10:11 skarindra

This doc is misleading. Espresso driver does not support files in .apks format. I've created a PR to actualize the README

is there any plan in the near future to improve appium espresso driver so it can support installed apks from bundletool?

fadeltd avatar Nov 05 '21 10:11 fadeltd

let me test as https://github.com/appium/appium-espresso-driver/pull/714#issuecomment-962056964 this weekend with https://github.com/KazuCocoa/AppBundleSample.

But as the pr comments, we assume espresso needs more tricks to work with .apks. As the updated readme, we think a single .apk generated by bundletool as universal for testing should work.

KazuCocoa avatar Nov 05 '21 17:11 KazuCocoa

We can use .apks with espresso driver. After unzipping .apks, use splits/base-master.apk to get the package and launch activity. Also signing info can be provided by the user to create espresso-server and it will work.

rajdeepv avatar Nov 06 '21 19:11 rajdeepv

I've tested with a sample app as .apks (not universal mode one) You can try https://github.com/appium/appium-espresso-driver/pull/718 out on your local if this works for you.

KazuCocoa avatar Nov 06 '21 19:11 KazuCocoa

@KazuCocoa I tried your solutions with below config :

  • Appium v1.22
  • Appium Espresso Driver v1.48 (from your branch)
  • As for the app, I generated the .apks with Appium keys

the app is successfully installed in my emulator but it seems like the espresso server couldn't be started, I keep getting error socket hang up and here's what I got from Appium log

2021-11-08 18:50:44:651 [W3C] Encountered internal error running command: A new session could not be created. Details: Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details. Check https://github.com/appium/appium-espresso-driver#troubleshooting regarding advanced session startup troubleshooting. 2021-11-08 18:50:44:651 [W3C] Error: Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details. Check https://github.com/appium/appium-espresso-driver#troubleshooting regarding advanced session startup troubleshooting. 2021-11-08 18:50:44:651 [W3C] at Object.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:94:35) 2021-11-08 18:50:44:651 [W3C] at condFn (/usr/local/lib/node_modules/appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:283:18) 2021-11-08 18:50:44:651 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:138:26) 2021-11-08 18:50:44:651 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:148:20) 2021-11-08 18:50:44:652 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:148:14) 2021-11-08 18:50:44:652 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:148:14) 2021-11-08 18:50:44:652 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:148:14) 2021-11-08 18:50:44:652 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:148:14) 2021-11-08 18:50:44:652 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:148:14) 2021-11-08 18:50:44:653 [W3C] at spin (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:148:14) 2021-11-08 18:50:44:653 [W3C] at waitForCondition (/usr/local/lib/node_modules/appium/node_modules/asyncbox/lib/asyncbox.js:155:10) 2021-11-08 18:50:44:653 [W3C] at EspressoRunner.startSession (/usr/local/lib/node_modules/appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:277:7) 2021-11-08 18:50:44:653 [W3C] at EspressoDriver.startEspressoSession (/usr/local/lib/node_modules/appium/node_modules/appium-espresso-driver/lib/driver.js:320:5) 2021-11-08 18:50:44:653 [W3C] at EspressoDriver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-espresso-driver/lib/driver.js:190:7) 2021-11-08 18:50:44:653 [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:387:35) 2021-11-08 18:50:44:657 [HTTP] <-- POST /wd/hub/session 500 41653 ms - 2216 2021-11-08 18:50:44:657 [HTTP]

skarindra avatar Nov 08 '21 19:11 skarindra

Did you check the logcat as the error message addressed? I guess something missing dependencies for the espresso server which requires to configure via https://github.com/appium/appium-espresso-driver#espresso-build-config

KazuCocoa avatar Nov 08 '21 19:11 KazuCocoa

Yes, here's what I got from logcat

AndroidRuntime: java.lang.NoSuchFieldError: No static field p0 of type Lkotlinx/coroutines/CoroutineExceptionHandler$a; in class Lkotlinx/coroutines/CoroutineExceptionHandler; or its superclasses (declaration of 'kotlinx.coroutines.CoroutineExceptionHandler' appears in /data/app/~~tsbyK1e6qxCn9PgoErx9tw==/io.appium.espressoserver.test-g7zlW5xXkZK9KeSw9o0Gxw==/base.apk)

I used this buildconfig

{
  "toolsVersions": {
    "gradle": "7.0.2",
    "androidGradlePlugin": "4.2.2",
    "compileSdk": 30,
    "buildTools": "30.0.2",
    "minSdk": 21,
    "targetSdk": 30
  },
  "additionalAppDependencies": [
    "com.google.android.material:material:1.2.1",
    "androidx.lifecycle:lifecycle-extensions:2.2.0"
  ]
}

It works fine with Espresso Driver v1.45.3 with universal apk, so I decided to made some adjustment there (based on what you did in https://github.com/appium/appium-espresso-driver/pull/718 ) and tested it on my local and it works well with .apks file also. So, I think I'm going to use this version first.

skarindra avatar Nov 09 '21 11:11 skarindra