Not able to launch app when using Espresso with Appium v1.22.3

Hi there, I need to start my Android app with "appium:automationName": "Espresso" driver for interacting with compose elements.

If I start app with "appium:automationName": "UiAutomator2" it works fine, but if I pass "appium:automationName": "Espresso" it fails.

I have app installed on the emulator, and same .apk file I’m passing in desired capabilities. This are my desired capabilities:

{
  "appium:automationName": "Espresso",
  "platformName": "Android",
  "appium:platformVersion": "13.0",
  "appium:deviceName": "emulator-5554",
  "appium:app": "/Users/nikola/Downloads/app-debug.apk",
  "appium:showGradleLog": true
}

Full Appium Server Log:

[HTTP] Waiting until the server is closed
[HTTP] Received server close event
[Appium] Welcome to Appium v1.22.3
[Appium] Non-default server args:
[Appium]   relaxedSecurityEnabled: true
[Appium]   allowInsecure: {
[Appium]   }
[Appium]   denyInsecure: {
[Appium]   }
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"alwaysMatch":{"appium:automationName":"Espresso","platformName":"Android","appium:platformVersion":"13.0","appium:deviceName":"emulator-5554","appium:app":"/Users/nikola/Downloads/app-debug.apk","appium:showGradleLog":true,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},"firstMatch":[{}]},"desiredCapabilities":{"appium:automationName":"Espresso","platformName":"Android","appium:platformVersion":"13.0","appium:deviceName":"emulator-5554","appium:app":"/Users/nikola/Downloads/app-debug.apk","appium:showGradleLog":true,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true}}
[W3C] Calling AppiumDriver.createSession() with args: [{"appium:automationName":"Espresso","platformName":"Android","appium:platformVersion":"13.0","appium:deviceName":"emulator-5554","appium:app":"/Users/nikola/Downloads/app-debug.apk","appium:showGradleLog":true,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},null,{"alwaysMatch":{"appium:automationName":"Espresso","platformName":"Android","appium:platformVersion":"13.0","appium:deviceName":"emulator-5554","appium:app":"/Users/nikola/Downloads/app-debug.apk","appium:showGradleLog":true,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},"firstMatch":[{}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1668434419720 (15:00:19 GMT+0100 (Central European Standard Time))
[Appium] Appium v1.22.3 creating new EspressoDriver (v1.45.3) session
[Appium] Applying relaxed security to 'EspressoDriver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
[BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[BaseDriver] Creating session with W3C capabilities: {
[BaseDriver]   "alwaysMatch": {
[BaseDriver]     "platformName": "Android",
[BaseDriver]     "appium:automationName": "Espresso",
[BaseDriver]     "appium:platformVersion": "13.0",
[BaseDriver]     "appium:deviceName": "emulator-5554",
[BaseDriver]     "appium:app": "/Users/nikola/Downloads/app-debug.apk",
[BaseDriver]     "appium:showGradleLog": true,
[BaseDriver]     "appium:ensureWebviewsHavePages": true,
[BaseDriver]     "appium:nativeWebScreenshot": true,
[BaseDriver]     "appium:newCommandTimeout": 3600,
[BaseDriver]     "appium:connectHardwareKeyboard": true
[BaseDriver]   },
[BaseDriver]   "firstMatch": [
[BaseDriver]     {}
[BaseDriver]   ]
[BaseDriver] }
[BaseDriver] The following capabilities were provided, but are not recognized by Appium:
[BaseDriver]   connectHardwareKeyboard
[BaseDriver] Session created with session id: c40be3d9-5383-430e-bc8e-23d111db7ae0
[BaseDriver] Using local app '/Users/nikola/Downloads/app-debug.apk'
[Espresso] Checking whether app is actually present
[Espresso] EspressoDriver version: 1.45.3
[ADB] Using 'adb' from '/Users/nikola/Library/Android/sdk/platform-tools/adb'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 start-server'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices
[ADB] Connected devices: [{"udid":"emulator-5554","state":"device"}]
[AndroidDriver] Looking for a device with Android '13.0.0'
[ADB] Setting device id to emulator-5554
[ADB] Getting device platform version
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 13
[AndroidDriver] Using device: emulator-5554
[ADB] Using 'adb' from '/Users/nikola/Library/Android/sdk/platform-tools/adb'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 start-server'
[ADB] Setting device id to emulator-5554
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 33
[ADB] Getting device platform version
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 13
[ADB] Device API level: 33
[Espresso] Relaxing hidden api policy
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1''
[AndroidDriver] Parsing package and activity from app manifest
[ADB] Package name: 'com.quickbit.android.app.debug'
[ADB] Main activity name: 'com.quickbit.android.app.activities.MainActivity'
[AndroidDriver] Parsed package and activity are: com.quickbit.android.app.debug/com.quickbit.android.app.activities.MainActivity
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('3.4.0' >= '3.4.0')
[ADB] There is no need to install/upgrade '/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
[ADB] Getting IDs of all 'io.appium.settings' processes
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'pgrep --help; echo $?''
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pgrep -f \(\[\[:blank:\]\]\|\^\)io\.appium\.settings\(\[\[:blank:\]\]\|\$\)'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[Logcat] Starting logs capture with command: /Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 logcat -v threadtime
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings get global animator_duration_scale'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings get global transition_animation_scale'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings get global window_animation_scale'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am broadcast -a io.appium.settings.animation -n io.appium.settings/.receivers.AnimationSettingReceiver --es setstatus disable'
[Espresso] Forwarding Espresso Server port 6791 to 8300
[ADB] Forwarding system: 8300 to device: 6791
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward tcp:8300 tcp:6791'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Checking app cert for /Users/nikola/Downloads/app-debug.apk
[ADB] Using the previously cached signature entry for 'app-debug.apk'
[ADB] sha256 hash did match for 'app-debug.apk'
[ADB] Getting install status for com.quickbit.android.app.debug
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package com.quickbit.android.app.debug'
[ADB] 'com.quickbit.android.app.debug' is installed
[ADB] Getting package info for 'com.quickbit.android.app.debug'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package com.quickbit.android.app.debug'
[ADB] The version name of the installed 'com.quickbit.android.app.debug' is greater or equal to the application version name ('3.0.0' >= '3.0.0')
[ADB] There is no need to install/upgrade '/Users/nikola/Downloads/app-debug.apk'
[AndroidDriver] Performing fast reset on 'com.quickbit.android.app.debug'
[ADB] Getting install status for com.quickbit.android.app.debug
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package com.quickbit.android.app.debug'
[ADB] 'com.quickbit.android.app.debug' is installed
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.quickbit.android.app.debug'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm clear com.quickbit.android.app.debug'
[AndroidDriver] Performed fast reset on the installed 'com.quickbit.android.app.debug' application (stop and clear)
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell "[ -e '/data/local/tmp/espresso.apppackage' ] && echo __PASS__"'
[Espresso] The previous target application package is unknown
[Espresso] Forcing Espresso server rebuild because of changed application package
[Espresso] Building espresso server in '/var/folders/2r/y843m8k13nx2klb_bl3s329c0000gn/T/espresso-server-emulator-5554'
[Espresso] The build folder root could be customized by changing the 'tmpDir' capability
[Espresso] Copying espresso server template from ('/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/espresso-server' to '/var/folders/2r/y843m8k13nx2klb_bl3s329c0000gn/T/espresso-server-emulator-5554')
[Espresso] Bulding espresso server
[Espresso] Beginning build with command './gradlew -PappiumTargetPackage=com.quickbit.android.app.debug app:assembleAndroidTest' in directory '/var/folders/2r/y843m8k13nx2klb_bl3s329c0000gn/T/espresso-server-emulator-5554'
[Espresso] Output from Gradle will be logged. To change this, use 'showGradleLog' desired capability
[Gradle] [STDOUT] Watching the file system is not supported on this operating system.
[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 FROM-CACHE
[Gradle] [STDOUT] > Task :app:checkDebugAarMetadata FROM-CACHE
[Gradle] [STDOUT] > Task :app:generateDebugResValues FROM-CACHE
[Gradle] [STDOUT] > Task :app:generateDebugResources UP-TO-DATE
[Gradle] [STDOUT] > Task :app:mergeDebugResources FROM-CACHE
[Gradle] [STDOUT] > Task :app:createDebugCompatibleScreenManifests FROM-CACHE
[Gradle] [STDOUT] > Task :app:extractDeepLinksDebug FROM-CACHE
[Gradle] [STDOUT] > Task :app:processDebugMainManifest FAILED
[Gradle] [STDERR] 
[Gradle] [STDERR] FAILURE: Build failed with an exception.
[Gradle] [STDERR] 
[Gradle] [STDERR] * What went wrong:
[Gradle] [STDERR] Execution failed for task ':app:processDebugMainManifest'.
[Gradle] [STDERR] > Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @7349102
[Gradle] [STDERR] 
[Gradle] [STDERR] * Try:
[Gradle] [STDERR] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[Gradle] [STDERR] 
[Gradle] [STDERR] * Get more help at https://help.gradle.org
[Gradle] [STDERR] 
[Gradle] [STDERR] BUILD FAILED in 5s
[Gradle] [STDOUT] 7 actionable tasks: 1 executed, 6 from cache
[Espresso] Unable to build Espresso server - Process ended with exitcode 1 (cmd: './gradlew -PappiumTargetPackage\=com.quickbit.android.app.debug app\:assembleAndroidTest')
[Espresso] Gradle error message:
[Espresso] 
[Espresso] [STDOUT] > Task :app:processDebugMainManifest FAILED,
[Espresso] [STDERR] ,
[Espresso] [STDERR] FAILURE: Build failed with an exception.,
[Espresso] [STDERR] ,
[Espresso] [STDERR] * What went wrong:,
[Espresso] [STDERR] Execution failed for task ':app:processDebugMainManifest'.,
[Espresso] [STDERR] > Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @7349102,
[Espresso] [STDERR] ,
[Espresso] [STDERR] * Try:,
[Espresso] [STDERR] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.,
[Espresso] [STDERR] ,
[Espresso] [STDERR] * Get more help at https://help.gradle.org,
[Espresso] [STDERR] ,
[Espresso] [STDERR] BUILD FAILED in 5s,
[Espresso] [STDOUT] 7 actionable tasks: 1 executed, 6 from cache
[Espresso] Deleting espresso session
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am broadcast -a io.appium.settings.animation -n io.appium.settings/.receivers.AnimationSettingReceiver --es setstatus enable'
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.quickbit.android.app.debug'
[Logcat] Stopping logcat capture
[Espresso] Restoring hidden api policy to the device default configuration
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy''
[ADB] Removing forwarded port socket connection: 8300 
[ADB] Running '/Users/nikola/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8300'
[BaseDriver] Event 'newSessionStarted' logged at 1668434427914 (15:00:27 GMT+0100 (Central European Standard Time))
[W3C] Encountered internal error running command: A new session could not be created. Details: Unable to build Espresso server - Process ended with exitcode 1 (cmd: './gradlew -PappiumTargetPackage\=com.quickbit.android.app.debug app\:assembleAndroidTest')
[W3C] Gradle error message:
[W3C] 
[W3C] [STDOUT] > Task :app:processDebugMainManifest FAILED,
[W3C] [STDERR] ,
[W3C] [STDERR] FAILURE: Build failed with an exception.,
[W3C] [STDERR] ,
[W3C] [STDERR] * What went wrong:,
[W3C] [STDERR] Execution failed for task ':app:processDebugMainManifest'.,
[W3C] [STDERR] > Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @7349102,
[W3C] [STDERR] ,
[W3C] [STDERR] * Try:,
[W3C] [STDERR] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.,
[W3C] [STDERR] ,
[W3C] [STDERR] * Get more help at https://help.gradle.org,
[W3C] [STDERR] ,
[W3C] [STDERR] BUILD FAILED in 5s,
[W3C] [STDOUT] 7 actionable tasks: 1 executed, 6 from cache. Check https://github.com/appium/appium-espresso-driver#troubleshooting regarding advanced session startup troubleshooting.
[W3C] Error: Unable to build Espresso server - Process ended with exitcode 1 (cmd: './gradlew -PappiumTargetPackage\=com.quickbit.android.app.debug app\:assembleAndroidTest')
[W3C] Gradle error message:
[W3C] 
[W3C] [STDOUT] > Task :app:processDebugMainManifest FAILED,
[W3C] [STDERR] ,
[W3C] [STDERR] FAILURE: Build failed with an exception.,
[W3C] [STDERR] ,
[W3C] [STDERR] * What went wrong:,
[W3C] [STDERR] Execution failed for task ':app:processDebugMainManifest'.,
[W3C] [STDERR] > Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @7349102,
[W3C] [STDERR] ,
[W3C] [STDERR] * Try:,
[W3C] [STDERR] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.,
[W3C] [STDERR] ,
[W3C] [STDERR] * Get more help at https://help.gradle.org,
[W3C] [STDERR] ,
[W3C] [STDERR] BUILD FAILED in 5s,
[W3C] [STDOUT] 7 actionable tasks: 1 executed, 6 from cache. Check https://github.com/appium/appium-espresso-driver#troubleshooting regarding advanced session startup troubleshooting.
[W3C]     at Object.errorAndThrow (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:94:35)
[W3C]     at ServerBuilder.runBuildProcess (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/lib/server-builder.js:188:11)
[W3C]     at ServerBuilder.build (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/lib/server-builder.js:69:5)
[W3C]     at EspressoRunner.buildNewModServer (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:187:5)
[W3C]     at EspressoRunner.installTestApk (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/lib/espresso-runner.js:145:7)
[W3C]     at EspressoDriver.initAUT (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/lib/driver.js:432:7)
[W3C]     at EspressoDriver.startEspressoSession (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/lib/driver.js:296:5)
[W3C]     at EspressoDriver.createSession (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-espresso-driver/lib/driver.js:188:7)
[W3C]     at AppiumDriver.createSession (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/lib/appium.js:387:35)
[HTTP] <-- POST /wd/hub/session 500 8200 ms - 3792

If I try to run espresso driver from command line with command: adb shell am instrument -w -e debug false io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner , I’m getting this:

INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner}
INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS_CODE: -1
android.util.AndroidException: INSTRUMENTATION_FAILED: io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
	at com.android.commands.am.Instrument.run(Instrument.java:534)
	at com.android.commands.am.Am.runInstrument(Am.java:208)
	at com.android.commands.am.Am.onRun(Am.java:85)
	at com.android.internal.os.BaseCommand.run(BaseCommand.java:62)
	at com.android.commands.am.Am.main(Am.java:54)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
java -version
openjdk version "18.0.2.1" 2022-08-18
OpenJDK Runtime Environment Zulu18.32+13-CA (build 18.0.2.1+1)
OpenJDK 64-Bit Server VM Zulu18.32+13-CA (build 18.0.2.1+1, mixed mode, sharing)

Anyone able to assist me on this one? Let me know if more information needed.
Thank you in advance!

Did you addEspresso framework into app? more -> https://developer.android.com/training/testing/espresso/setup