appium-espresso-driver: A new session could not be created.

Continuation of the error in issue #938 , I have tried to clean dependencies, update gradle, and I have updated to the plugin that you have recommended, 2.26.10, and I have tried to do the gradle wrapper command as suggested by my colleague, and I got this error:

gradle wrapper :

FAILURE: Build failed with an exception.

* Where:
Build file '/home/.appium/node_modules/appium-espresso-driver/espresso-server/app/build.gradle.kts' line: 1

* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
   > Failed to create service 'com.android.build.gradle.options.ProjectOptionService_3efaac46-cbfd-49b3-ac96-410f56bf4beb'.
      > Could not create an instance of type com.android.build.gradle.options.ProjectOptionService.
         > Cannot obtain value from provider of Gradle property 'android.testInstrumentationRunnerArguments.package' at configuration time.
           Use a provider returned by 'forUseAtConfigurationTime()' instead.

./gradlew clean build :


> Task :app:testDebugUnitTest

io.appium.espressoserver.EspressoServerRunnerTest > startEspressoServer FAILED
    java.lang.NoClassDefFoundError at EspressoLink.android.kt:71
        Caused by: java.lang.ExceptionInInitializerError at Preconditions.java:2

145 tests completed, 1 failed, 1 skipped

> Task :app:testDebugUnitTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:testDebugUnitTest'.
> There were failing tests. See the report at: file:///home/.appium/node_modules/appium-espresso-driver/espresso-server/app/build/reports/tests/testDebugUnitTest/index.html

And the error to try launch appium:

[AppiumDriver@0b2e] Event 'newSessionStarted' logged at 1698314362733 (11:59:22 GMT+0200 (hora de verano de Europa central))
[AppiumDriver@0b2e] 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.
[AppiumDriver@0b2e] 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.
[AppiumDriver@0b2e]     at Object.wrappedLogger.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/@appium/support/lib/logging.js:115:34)
[AppiumDriver@0b2e]     at condFn (/home/.appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:313:20)
[AppiumDriver@0b2e]     at spin (/home/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:221:26)
[AppiumDriver@0b2e]     at spin (/home/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:231:20)
[AppiumDriver@0b2e]     at spin (/home/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:231:14)
[AppiumDriver@0b2e]     at spin (/home/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:231:14)
[AppiumDriver@0b2e]     at waitForCondition (/home/.appium/node_modules/appium-espresso-driver/node_modules/asyncbox/lib/asyncbox.js:238:10)
[AppiumDriver@0b2e]     at EspressoRunner.startSession (/home/.appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:307:7)
[AppiumDriver@0b2e]     at EspressoDriver.startEspressoSession (/home/.appium/node_modules/appium-espresso-driver/lib/driver.js:439:5)
[AppiumDriver@0b2e]     at EspressoDriver.createSession (/home/.appium/node_modules/appium-espresso-driver/lib/driver.js:245:7)
[AppiumDriver@0b2e]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:374:35)
[HTTP] <-- POST /session 500 76210 ms - 1897
[HTTP] 



Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: 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. 
Build info: version: '4.9.1', revision: 'eb2032df7f'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.2.0-34-generic', java.version: '17.0.9'
Driver info: io.appium.java_client.AppiumDriver
Command: [null, newSession {capabilities=[{appium:appActivity=com.sec.android.app.popupcalculator.Calculator, appium:appPackage=com.sec.android.app.popupcalculator, appium:automationName=Espresso, appium:forceEspressoRebuild=true, appium:noReset=true, platformName=ANDROID, appium:showGradleLog=true}], desiredCapabilities=Capabilities {appActivity: com.sec.android.app.popupca..., appPackage: com.sec.android.app.popupca..., appium:automationName: Espresso, forceEspressoRebuild: true, noReset: true, platformName: ANDROID, showGradleLog: true}}]
Capabilities {appActivity: com.sec.android.app.popupca..., appPackage: com.sec.android.app.popupca..., appium:automationName: Espresso, forceEspressoRebuild: true, noReset: true, platformName: ANDROID, showGradleLog: true}
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:133)
	at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102)
	at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:182)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
	at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:274)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:112)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:137)
	at com.example.test.AppiumTests.openApp(AppiumTests.java:69)
	at com.example.test.AppiumTests.main(AppiumTests.java:16)`

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Usually the driver does it automatically with default settings. E.g. you provide the path to your .apk as app capability, then it gets signed and merged into a single test package. After this package is installed to the device under test and is starting properly (the merge operation demands there are no conflicts between your app dependencies and the injected Espresso server) one may provide noReset=true in order for it to be reused.