appium / appium-espresso-driver

Espresso integration for Appium
Apache License 2.0
193 stars 75 forks source link

Espresso server process has been unexpectedly terminated #820

Open aravindaw opened 2 years ago

aravindaw commented 2 years ago

I'm trying to start the espresso driver and it crashes when instantiating the instruments. I tried a couple of configurations but with no success. I kept the Appium cap versions and app config versions exactly the same. Also tried to find a solution in here but didn't work as well.

Environment

Java:11 Appium:1.22.3-4 GUI

Appium config:

      platform: 'Android',
      port: 4723,
      deviceName: 'Pixel',
      automationName: 'Espresso',
      platformVersion: '12',
      showGradleLog: true,
      noSign:true,
      forceEspressoRebuild:true,

espressoBuildConfig:

{
   "toolsVersions":{
      "buildTools":"30.0.3",
      "kotlin":"1.7.10",
      "gradle":"7.4",
      "compileSdk":"32",
      "minSdk":"28"
   },
   "additionalAppDependencies":[
      "androidx.test:runner:1.4.0",
      "androidx.annotation:annotation:1.5.0",
      "junit:junit:4.13.2",
      "androidx.test.espresso:espresso-core:3.4.0"
   ]
}

Appium log

[2022-10-04 11:37:55][Espresso] Starting Espresso Server v1.45.3 with cmd: adb shell am instrument -w -e debug false -e disableAnalytics true io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
[2022-10-04 11:37:55][ADB] Creating ADB subprocess with args: ["-P",5037,"-s","emulator-5554","shell","am","instrument","-w","-e","debug",false,"-e","disableAnalytics",true,"io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner"]
[2022-10-04 11:37:55][Espresso] Waiting up to 45000ms for Espresso server to be online
[2022-10-04 11:37:55][WD Proxy] Matched '/status' to command name 'getStatus'
[2022-10-04 11:37:55][WD Proxy] Proxying [GET /status] to [GET http://localhost:8300/status] with no body
[2022-10-04 11:37:55][WD Proxy] socket hang up
[2022-10-04 11:37:55][Espresso] [Instrumentation] INSTRUMENTATION_RESULT: shortMsg=Process crashed.
[2022-10-04 11:37:55][Espresso] INSTRUMENTATION_CODE: 0
[2022-10-04 11:37:56][WD Proxy] Matched '/status' to command name 'getStatus'
[2022-10-04 11:37:56][WD Proxy] Proxying [GET /status] to [GET http://localhost:8300/status] with no body
[2022-10-04 11:37:56][WD Proxy] socket hang up
[2022-10-04 11:37:56][WD Proxy] Matched '/status' to command name 'getStatus'
[2022-10-04 11:37:56][WD Proxy] Proxying [GET /status] to [GET http://localhost:8300/status] with no body
[2022-10-04 11:37:56][WD Proxy] socket hang up
[2022-10-04 11:37:56][Espresso] Instrumentation process exited with code 0 from signal null
[2022-10-04 11:37:57][Espresso] Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details
[2022-10-04 11:37:57][Espresso] Deleting espresso session

Logcat

java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~T7FVk4Aqm4p15IEFMnxD_A==/io.appium.espressoserver.test-lci8S2c8RIr31hO7d7Cmrw==/base.apk", zip file "/data/app/~~zkI0sTIYNBWokBXOR52asw==/com.ravin.testapp-qlia8MYp4N3LzcFdKsI2JQ==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]
    at android.app.ActivityThread.initInstrumentation(ActivityThread.java:6888)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6672)
    at android.app.ActivityThread.access$1500(ActivityThread.java:256)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2090)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7842)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~T7FVk4Aqm4p15IEFMnxD_A==/io.appium.espressoserver.test-lci8S2c8RIr31hO7d7Cmrw==/base.apk", zip file "/data/app/~~zkI0sTIYNBWokBXOR52asw==/com.ravin.testapp-qlia8MYp4N3LzcFdKsI2JQ==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.ActivityThread.initInstrumentation(ActivityThread.java:6884)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6672) 
    at android.app.ActivityThread.access$1500(ActivityThread.java:256) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2090) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loopOnce(Looper.java:201) 
    at android.os.Looper.loop(Looper.java:288) 
    at android.app.ActivityThread.main(ActivityThread.java:7842) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 

If I run adb shell am instrument -w -e debug false -e disableAnalytics true io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner locally I get the same exception as the appium log.

➜  testApp adb shell am instrument -w -e debug false -e disableAnalytics true io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0
KazuCocoa commented 2 years ago

I haven't seen this message... but it said androidx.test.runner.AndroidJUnitRunner did not exist

Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/T7FVk4Aqm4p15IEFMnxD_A==/io.appium.espressoserver.test-lci8S2c8RIr31hO7d7Cmrw==/base.apk", zip file "/data/app/zkI0sTIYNBWokBXOR52asw==/com.ravin.testapp-qlia8MYp4N3LzcFdKsI2JQ==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]

Could you try out appium 2 and latest espresso driver?

VitorMarinheiro commented 2 years ago

Hello guys, I think the error I'm getting is the same error as @aravindaw .

[AppiumDriver@6b82] 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.

Environment

Java:11 Appium:v2.0.0-beta.44

Appium config:

  platform: 'Android',
  port: 4723,
  deviceName: 'emulator-5554',
  automationName: 'Espresso',
  platformVersion: '11',
  showGradleLog: true,
  forceEspressoRebuild:true

Appium log:

  [debug] [ADB] Install command stdout: Serving...
  [debug] [ADB] Performing Incremental Install
  [debug] [ADB] Success
  [debug] [ADB] Install command complete in 3541 ms
  [EspressoDriver@f528 (3c75677a)] Installed Espresso Test Server apk '/var/folders/px/nb05f7_x6z590chpgnj86kr80000gs/T/io.appium.espressoserver.test_2.11.0_br.com.xxxx.xxx.dev_emulator-5554.apk' (pkg: 'io.appium.espressoserver.test')
  [ADB] Adding packages ["io.appium.settings","io.appium.espressoserver.test"] to Doze whitelist
  [debug] [ADB] Got the following command chunks to execute: [["dumpsys","deviceidle","whitelist","+io.appium.settings",";","dumpsys","deviceidle","whitelist","+io.appium.espressoserver.test",";"]]
  [debug] [ADB] Running '/Users/bi004330/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys deviceidle whitelist +io.appium.settings ; dumpsys deviceidle whitelist +io.appium.espressoserver.test ;'
  [debug] [EspressoDriver@f528 (3c75677a)] Performing cleanup of automation leftovers
  [debug] [EspressoDriver@f528 (3c75677a)] No obsolete sessions have been detected (socket hang up)
  [EspressoDriver@f528 (3c75677a)] Starting Espresso Server v2.11.0 with cmd: adb shell am instrument -w -e debug false -e disableAnalytics true io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
  [debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","emulator-5554","shell","am","instrument","-w","-e","debug",false,"-e","disableAnalytics",true,"io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner"]
  [EspressoDriver@f528 (3c75677a)] Waiting up to 60000ms for Espresso server to be online
  [debug] [EspressoDriver@f528 (3c75677a)] Matched '/status' to command name 'getStatus'
  [debug] [EspressoDriver@f528 (3c75677a)] Proxying [GET /status] to [GET http://127.0.0.1:8300/status] with no body
  [EspressoDriver@f528 (3c75677a)] socket hang up
  [debug] [EspressoDriver@f528 (3c75677a)] Matched '/status' to command name 'getStatus'
  [debug] [EspressoDriver@f528 (3c75677a)] Proxying [GET /status] to [GET http://127.0.0.1:8300/status] with no body
  [EspressoDriver@f528 (3c75677a)] socket hang up
  [debug] [EspressoDriver@f528 (3c75677a)] Matched '/status' to command name 'getStatus'
  [debug] [EspressoDriver@f528 (3c75677a)] Proxying [GET /status] to [GET http://127.0.0.1:8300/status] with no body
  [EspressoDriver@f528 (3c75677a)] socket hang up
  [debug] [EspressoDriver@f528 (3c75677a)] Matched '/status' to command name 'getStatus'
  [debug] [EspressoDriver@f528 (3c75677a)] Proxying [GET /status] to [GET http://127.0.0.1:8300/status] with no body
  [EspressoDriver@f528 (3c75677a)] socket hang up
  [debug] [EspressoDriver@f528 (3c75677a)] Matched '/status' to command name 'getStatus'
  [debug] [EspressoDriver@f528 (3c75677a)] Proxying [GET /status] to [GET http://127.0.0.1:8300/status] with no body
  [EspressoDriver@f528 (3c75677a)] socket hang up
  [debug] [EspressoDriver@f528 (3c75677a)] Matched '/status' to command name 'getStatus'
  [debug] [EspressoDriver@f528 (3c75677a)] Proxying [GET /status] to [GET http://127.0.0.1:8300/status] with no body
  [EspressoDriver@f528 (3c75677a)] socket hang up
  [debug] [EspressoDriver@f528 (3c75677a)] [Instrumentation] INSTRUMENTATION_RESULT: shortMsg=Process crashed.
  [debug] [EspressoDriver@f528 (3c75677a)] INSTRUMENTATION_CODE: 0
  [debug] [EspressoDriver@f528 (3c75677a)] Matched '/status' to command name 'getStatus'
  [debug] [EspressoDriver@f528 (3c75677a)] Proxying [GET /status] to [GET http://127.0.0.1:8300/status] with no body
  [EspressoDriver@f528 (3c75677a)] socket hang up
  [EspressoDriver@f528 (3c75677a)] Instrumentation process exited with code 0 from signal null
  [EspressoDriver@f528 (3c75677a)] Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details
  [debug] [EspressoDriver@f528 (3c75677a)] Deleting espresso session
KazuCocoa commented 2 years ago

Only adb log helps to find possible reasons. Usually appium version is not related. Basically appium-espresso-driver version, the app under test and Android OS's combination

satyasree-byte commented 1 year ago

Facing the same issue. with appium 1.22.3. Any update or solution for this. Please let us know

Stephane-Tostivin commented 1 year ago

Facing the same issue (cf. ticket https://github.com/appium/appium-espresso-driver/issues/839), working with a dev on analyzing and testing solutions but no progress so far...

uc-rreis commented 1 year ago

Bumped into this same issue appium version Appium v2.0.0-beta.48

[debug] [ADB] Removing forwarded port socket connection: 8300 
[debug] [ADB] Running '/Users/.../Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8300'
[debug] [AppiumDriver@51eb] Event 'newSessionStarted' logged at 1673373330766 (17:55:30 GMT+0000 (Western European Standard Time))
[debug] [AppiumDriver@51eb] 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.
[debug] [AppiumDriver@51eb] 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.
[debug] [AppiumDriver@51eb]     at Object.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/@appium/support/lib/logging.js:115:34)
[debug] [AppiumDriver@51eb]     at condFn (/Users/<user>/.appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:287:20)
[debug] [AppiumDriver@51eb]     at spin (/Users/<user>/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:221:26)
[debug] [AppiumDriver@51eb]     at spin (/Users/<user>/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:231:20)
[debug] [AppiumDriver@51eb]     at waitForCondition (/Users/<user>/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:238:10)
[debug] [AppiumDriver@51eb]     at EspressoRunner.startSession (/Users/<user>/.appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:281:7)
[debug] [AppiumDriver@51eb]     at EspressoDriver.startEspressoSession (/Users/<user>/.appium/node_modules/appium-espresso-driver/lib/driver.js:444:5)
[debug] [AppiumDriver@51eb]     at EspressoDriver.createSession (/Users/<user>/.appium/node_modules/appium-espresso-driver/lib/driver.js:224:7)
[debug] [AppiumDriver@51eb]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:336:35)
[HTTP] <-- POST /session 500 19648 ms - 1756
[HTTP] 
^C[Appium] Received SIGINT - shutting down
[debug] [AppiumDriver@51eb] There are no active sessions for cleanup
[HTTP] Waiting until the server is closed
[HTTP] Received server close event
<user>@ Rui Reis-C02GG0LXML85 test-js % appium
[Appium] Welcome to Appium v2.0.0-beta.48
[Appium] Attempting to load driver uiautomator2...
[debug] [Appium] Requiring driver at /Users/.../.appium/node_modules/appium-uiautomator2-driver
[Appium] Attempting to load driver xcuitest...
[debug] [Appium] Requiring driver at /Users/.../.appium/node_modules/appium-xcuitest-driver
[Appium] Attempting to load driver espresso...
[debug] [Appium] Requiring driver at /Users/.../.appium/node_modules/appium-espresso-driver
(node:20032) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723