Error when trying to use espresso instead of uiautomator

Hi,

When I try using appium with espresso I get an error and app does not even start.

If I replace the automation name capability by uiautomator2 it works fine.

Here are my capabilities :

cap.setCapability(MobileCapabilityType.AUTOMATION_NAME,“espresso”);
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, “9.0”);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, “EmulatorP4_9”);
cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, “com.myapp”);
cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, “com.myapp.SplashActivity”)

Am I forgetting something ?

Thanks

1 Like

Maybe forget to add Espresso into test build -> https://developer.android.com/training/testing/ui-testing/espresso-testing?

‘uiautomator2’ does not need any changes in app but Espresso needs.

also read https://github.com/appium/appium-espresso-driver

Thank you for your answer,

I checked with the developper, the following code is present in the app dependencies:

androidTestImplementation(Libs.AndroidX.AndroidTest.espresso)
androidx.test.espresso:espresso-core:3.4.0

Is that what adding Espresso into test build means ?

never used Espresso. just have theoretical knowledge. second thing is no obfuscation. check link -> https://github.com/appium/appium-espresso-driver#troubleshooting

capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, “espresso”);
capabilities.setCapability(“espressoBuildConfig”,
“{“additionalAndroidTestDependencies”: {“androidx.lifecycle:lifecycle-extensions”:2.2.0, “androidx.activity:activity”:“1.3.1”, “androidx.fragment:fragment”:“1.2.0”}}}”);

what is wrong with this, what I’m missing?

Possible missing build your test app with espresso framework.

This is my current EspressoBuildConfig, now while EspressoDriver creation EspressoServer is getting terminated.
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ESPRESSO);
capabilities.setCapability(“appium:espressoBuildConfig:”,
“{ additionalAndroidTestDependencies: [androidx.lifecycle:lifecycle-extensions:2.2.0, androidx.activity:activity:1.3.1, androidx.fragment:fragment:1.2.0, org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10, com.google.android.material:material:1.3.0, androidx.lifecycle:lifecycle-runtime-ktx:2.3.1, androidx.compose.runtime:runtime-livedata:1.0.2, androidx.lifecycle:lifecycle-livedata-ktx:2.3.1, androidx.appcompat:appcompat:1.2.0 ]}”);
capabilities.setCapability(“appium:forceEspressoRebuild”, true);
capabilities.setCapability(“appium:showGradleLog”, true);
capabilities.setCapability(“appium:espressoServerLaunchTimeout”, 60 * 1000);
Appium version: v1.20.2
Android SDK Build Tools version: 29.0.2

Latest Eclipse Console Logs shows:
[Espresso] Building espresso server in ‘C:\Users\xxxxx\AppData\Local\Temp\espresso-server-ZY224P7335’
[Espresso] Installed Espresso Test Server apk
[Espresso] Starting Espresso Server v1.41.0 with cmd: adb shell am instrument -w -e debug false io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
[Espresso] Waiting up to 60000ms for Espresso server to be online
[WD Proxy] socket hang up
[WD Proxy] socket hang up
[WD Proxy] socket hang up
[WD Proxy] socket hang up
[WD Proxy] socket hang up
[Espresso] Instrumentation process exited with code 1 from signal null
[Espresso] Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details
[Espresso] Restoring hidden api policy to the device default configuration
[HTTP] ← POST /wd/hub/session 500 434583 ms - 2778

Driver info: driver.version: CreateDriver
remote stack trace: Error: Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details. Check GitHub - appium/appium-espresso-driver: Espresso integration for Appium regarding advanced session startup troubleshooting.
2022-02-21 14:59:45,838 [TestNG-tests-1] ERROR com.premise.driver.CreateDriver - Throwable while createLocalDriver:::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: Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details. Check GitHub - appium/appium-espresso-driver: Espresso integration for Appium regarding advanced session startup troubleshooting.
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’

It still does not answer - Does test build have espresso config? NOT your capability.

Here is the Eclipse Console Logs:
Gradle seems to be taking these espresso config

[Espresso] Building espresso server in ‘C:\Users\asimk\AppData\Local\Temp\espresso-server-ZY224P7335’
[Gradle] [STDOUT] WARNING: The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.1.1.
[Gradle] [STDOUT] Android SDK Build Tools 29.0.2 will be used.
[Gradle] [STDOUT] To suppress this warning, remove “buildToolsVersion ‘28.0.3’” from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

[Gradle] [STDOUT] > Task :app:preBuild UP-TO-DATE

[Gradle] [STDOUT] > Task :app:preDebugBuild UP-TO-DATE

[Gradle] [STDOUT] > Task :app:compileDebugAidl NO-SOURCE

[Gradle] [STDOUT] > Task :app:compileDebugRenderscript NO-SOURCE

[Gradle] [STDOUT] > Task :app:generateDebugBuildConfig

[Gradle] [STDOUT] > Task :app:checkDebugAarMetadata

[Gradle] [STDOUT] > Task :app:generateDebugResValues

[Gradle] [STDOUT] > Task :app:generateDebugResources

[Gradle] [STDOUT] > Task :app:mergeDebugResources

[Gradle] [STDOUT] > Task :app:createDebugCompatibleScreenManifests

[Gradle] [STDOUT] > Task :app:extractDeepLinksDebug

[Gradle] [STDOUT] > Task :app:processDebugMainManifest

[Gradle] [STDOUT] > Task :app:processDebugManifest

[Gradle] [STDOUT] > Task :app:preDebugAndroidTestBuild SKIPPED

[Gradle] [STDOUT] > Task :app:compileDebugAndroidTestAidl NO-SOURCE

[Gradle] [STDOUT] > Task :app:javaPreCompileDebug

[Gradle] [STDOUT] > Task :app:processDebugAndroidTestManifest

[Gradle] [STDOUT] > Task :app:compileDebugAndroidTestRenderscript NO-SOURCE

[Gradle] [STDOUT] > Task :app:generateDebugAndroidTestBuildConfig

[Gradle] [STDOUT] > Task :app:checkDebugAndroidTestAarMetadata

[Gradle] [STDOUT] > Task :app:generateDebugAndroidTestResValues

[Gradle] [STDOUT] > Task :app:generateDebugAndroidTestResources

[Gradle] [STDOUT] > Task :app:mergeDebugAndroidTestResources

[Gradle] [STDOUT] > Task :app:processDebugManifestForPackage

[Gradle] [STDOUT] > Task :app:javaPreCompileDebugAndroidTest

[Gradle] [STDOUT] > Task :app:processDebugResources

[Gradle] [STDOUT] > Task :app:processDebugAndroidTestResources

[Gradle] [STDOUT] > Task :app:compileDebugKotlin

[Gradle] [STDOUT] > Task :app:compileDebugJavaWithJavac

[Gradle] [STDOUT] > Task :app:bundleDebugClasses

[Gradle] [STDOUT] > Task :app:mergeDebugAndroidTestShaders

[Gradle] [STDOUT] > Task :app:compileDebugAndroidTestShaders NO-SOURCE

[Gradle] [STDOUT] > Task :app:generateDebugAndroidTestAssets UP-TO-DATE

[Gradle] [STDOUT] > Task :app:mergeDebugAndroidTestAssets

[Gradle] [STDOUT] > Task :app:compileDebugAndroidTestKotlin

[Gradle] [STDOUT] > Task :app:compileDebugAndroidTestJavaWithJavac

[Gradle] [STDOUT] > Task :app:compileDebugAndroidTestSources

[Gradle] [STDOUT] > Task :app:compressDebugAndroidTestAssets

[Gradle] [STDOUT] > Task :app:processDebugAndroidTestJavaRes NO-SOURCE

[Gradle] [STDOUT] > Task :app:mergeDebugAndroidTestJniLibFolders

[Gradle] [STDOUT] > Task :app:checkDebugAndroidTestDuplicateClasses

[Gradle] [STDOUT] > Task :app:mergeDebugAndroidTestNativeLibs

[Gradle] [STDOUT] > Task :app:mergeDebugAndroidTestJavaResource

[Gradle] [STDOUT] > Task :app:dexBuilderDebugAndroidTest

[Gradle] [STDOUT] > Task :app:validateSigningDebugAndroidTest

[Gradle] [STDOUT] > Task :app:mergeExtDexDebugAndroidTest

[Gradle] [STDOUT] > Task :app:mergeDexDebugAndroidTest

[Gradle] [STDOUT] > Task :app:packageDebugAndroidTest

[Gradle] [STDOUT] > Task :app:assembleDebugAndroidTest

[Gradle] [STDOUT] > Task :app:assembleAndroidTest

[Gradle] [STDOUT]

[Gradle] [STDOUT] BUILD SUCCESSFUL in 2m 36s

[Gradle] [STDOUT] 35 actionable tasks: 35 executed

[ADB] Using ‘apksigner.jar’ from ‘C:\Android\build-tools\29.0.2\lib\apksigner.jar’
[ADB] ‘C:\Users\asimk\AppData\Local\Temp\io.appium.espressoserver.test_1.41.0_com.premise.android.qa.debug_ZY224P7335.apk’ is signed with a non-default certificate
[ADB] Using ‘zipalign.exe’ from ‘C:\Android\build-tools\29.0.2\zipalign.exe’
[ADB] io.appium.espressoserver.test was successfully uninstalled
[Espresso] Uninstalled the obsolete Espresso server package from the device under test
[Espresso] Installing Espresso Test Server apk from the target device (path: ‘C:\Users\asimk\AppData\Local\Temp\io.appium.espressoserver.test_1.41.0_com.premise.android.qa.debug_ZY224P7335.apk’)
[ADB] The application at ‘C:\Users\asimk\AppData\Local\Temp\io.appium.espressoserver.test_1.41.0_com.premise.android.qa.debug_ZY224P7335.apk’ will not be cached, because the device under test has confirmed the support of streamed installs
[ADB] The installation of ‘io.appium.espressoserver.test_1.41.0_com.premise.android.qa.debug_ZY224P7335.apk’ took 2048ms
[Espresso] Installed Espresso Test Server apk ‘C:\Users\asimk\AppData\Local\Temp\io.appium.espressoserver.test_1.41.0_com.premise.android.qa.debug_ZY224P7335.apk’ (pkg: ‘io.appium.espressoserver.test’)
[ADB] Adding packages [“io.appium.settings”,“io.appium.espressoserver.test”] to Doze whitelist
[Espresso] Starting Espresso Server v1.41.0 with cmd: adb shell am instrument -w -e debug false io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
[Espresso] Waiting up to 60000ms for Espresso server to be online
[WD Proxy] socket hang up
[WD Proxy] socket hang up
[WD Proxy] socket hang up
[Espresso] Instrumentation process exited with code 1 from signal null
[Espresso] Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details
[Espresso] Restoring hidden api policy to the device default configuration
[HTTP] ← POST /wd/hub/session 500 201730 ms - 2472
[HTTP]
2022-02-21 17:54:00,559 [TestNG-tests-1] ERROR com.premise.driver.CreateDriver - Throwable while createLocalDriver:::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: Espresso server process has been unexpectedly terminated. Check the Appium server log and the logcat output for more details. Check GitHub - appium/appium-espresso-driver: Espresso integration for Appium regarding advanced session startup troubleshooting.

@AlekseiEspresso driver Unable to build Espresso server - Process ended with exitcode 1.txt (79.2 KB)

[Gradle] [STDERR] Execution failed for task ‘:app:processDebugMainManifest’.

Eclipse IDE

How to fix this issue now?
Appium version: v1.23.0-beta.0
EspressoDriver version: 1.50.1
Console 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: Unable to build Espresso server - Process ended with exitcode 1 (cmd: ‘gradlew.bat -PappiumTargetPackage=com.premise.android.qa.debug app:assembleAndroidTest’)

Sorry. Never used espresso…

1 Like