Appium 1.8.1 trying to get espresso running

After hitting a previously posted error with UiAutomator2, I wanted to try out espresso… but it seems to be barfing right out of the box (at least through selenium grid):

        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(CapabilityType.BROWSER_NAME, "");
        cap.setCapability("platformName", "Android");
        cap.setCapability("deviceName", "ANY");
        cap.setCapability("platformVersion", "ANY");
        // cap.setCapability("automationName", AutomationName.ANDROID_UIAUTOMATOR2);
        cap.setCapability("automationName", AutomationName.ESPRESSO);
        cap.setCapability("appPackage", "com.samsung.android.app.memo");
        cap.setCapability("appActivity", "com.samsung.android.app.memo.Main");
        cap.setCapability("resetKeyboard", true);
        cap.setCapability("unicodeKeyboard", true);
        cap.setCapability("clearSystemFiles", true);
        cap.setCapability("autoGrantPermissions", true);
        cap.setCapability("disableAndroidWatchers", true);
        cap.setCapability("ignoreUnimportantViews", true);

        driver = new AndroidDriver<>(new URL(TestProperties.getSeleniumHubUrl()), cap);

And the appium.log error states:

018-07-09 19:55:21:353 - [debug] [ADB] Compiled manifest
2018-07-09 19:55:21:354 - [debug] [ADB] Inserting manifest, src: /Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/appium-espresso-driver/espresso-server/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk dst: /var/folders/n5/yjccqg_n37n3tl2j
4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk
2018-07-09 19:55:21:355 - [debug] [ADB] Unzipping /var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/AndroidManifest.xml.apk
2018-07-09 19:55:21:356 - [debug] [ADB] Testing zip archive: '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/AndroidManifest.xml.apk'
2018-07-09 19:55:21:372 - [debug] [ADB] Unzip successful
2018-07-09 19:55:21:412 - [debug] [ADB] Testing new tmp apk
2018-07-09 19:55:21:412 - [debug] [ADB] Testing zip archive: '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk'
2018-07-09 19:55:21:414 - [debug] [ADB] Moving manifest
2018-07-09 19:55:21:441 - [debug] [ADB] Inserted manifest.
2018-07-09 19:55:21:442 - [Espresso] Repackaged espresso server ready: '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk'
2018-07-09 19:55:21:442 - [debug] [ADB] Checking app cert for /var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk
2018-07-09 19:55:21:443 - [debug] [ADB] Starting '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/build-tools/25.0.2/apksigner' with args 'verify,--print-certs,/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk'
2018-07-09 19:55:21:713 - [debug] [ADB] '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk' is not signed with debug cert.
2018-07-09 19:55:21:714 - [debug] [ADB] Zip-aligning '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk'
2018-07-09 19:55:21:745 - [debug] [ADB] Signing '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk' with default cert
2018-07-09 19:55:21:745 - [debug] [ADB] Starting '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/build-tools/25.0.2/apksigner' with args 'sign,--key,/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/appium-adb/keys/testkey.pk8,--cert,/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/appium-adb/keys/testkey.x509.pem,/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk'
2018-07-09 19:55:22:300 - [debug] [ADB] Getting install status for io.appium.espressoserver.test
2018-07-09 19:55:22:300 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell pm list packages io.appium.espressoserver.test'
2018-07-09 19:55:22:862 - [debug] [ADB] App is not installed
2018-07-09 19:55:22:862 - [debug] [ADB] App '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk' not installed. Installing
2018-07-09 19:55:22:862 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 install /var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk'
2018-07-09 19:55:23:516 - [HTTP] --> GET /wd/hub/status
2018-07-09 19:55:23:516 - [HTTP] {}
2018-07-09 19:55:23:517 - [debug] [W3C] Calling AppiumDriver.getStatus() with args: []
2018-07-09 19:55:23:529 - [debug] [W3C] Responding to client with driver.getStatus() result: {"build":{"version":"1.8.1","revision":null}}
2018-07-09 19:55:23:530 - [HTTP] <-- GET /wd/hub/status 200 14 ms - 55
2018-07-09 19:55:23:531 - [HTTP] 
2018-07-09 19:55:26:341 - [debug] [ADB] Install command stdout: Success
2018-07-09 19:55:26:342 - [Espresso] Installed Espresso Test Server apk '/var/folders/n5/yjccqg_n37n3tl2j4klvc4cw0000gn/T/io.appium.espressoserver.test_1.0.0-beta.9_com.samsung.android.app.memo.apk' (pkg: 'io.appium.espressoserver.test')
2018-07-09 19:55:26:343 - [Espresso] Starting Espresso Server v1.0.0-beta.9 with cmd: am instrument -w -e debug false io.appium.espressoserver.test/android.support.test.runner.AndroidJUnitRunner
2018-07-09 19:55:26:343 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell am instrument -w -e debug false io.appium.espressoserver.test/android.support.test.runner.AndroidJUnitRunner'
2018-07-09 19:55:26:350 - [Espresso] Waiting for Espresso to be online...
2018-07-09 19:55:26:352 - [debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:7334/status] with no body
2018-07-09 19:55:26:915 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell am instrument -w -e debug false io.appium.espressoserver.test/android.support.test.runner.AndroidJUnitRunner'
2018-07-09 19:55:27:368 - [debug] [Espresso] Deleting espresso session
2018-07-09 19:55:27:368 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell am broadcast -a io.appium.settings.animation -n io.appium.settings/.receivers.AnimationSettingReceiver --es setstatus enable'
2018-07-09 19:55:28:539 - [HTTP] --> GET /wd/hub/status
2018-07-09 19:55:28:539 - [HTTP] {}
2018-07-09 19:55:28:539 - [debug] [W3C] Calling AppiumDriver.getStatus() with args: []
2018-07-09 19:55:28:550 - [debug] [W3C] Responding to client with driver.getStatus() result: {"build":{"version":"1.8.1","revision":null}}
2018-07-09 19:55:28:555 - [HTTP] <-- GET /wd/hub/status 200 12 ms - 55
2018-07-09 19:55:28:555 - [HTTP] 
2018-07-09 19:55:30:571 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell am force-stop com.samsung.android.app.memo'
2018-07-09 19:55:30:660 - [debug] [Logcat] Stopping logcat capture
2018-07-09 19:55:30:662 - [debug] [ADB] Removing forwarded port socket connection: 7334 
2018-07-09 19:55:30:662 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 forward --remove tcp\:7334'
2018-07-09 19:55:30:672 - [debug] [BaseDriver] Event 'newSessionStarted' logged at 1531166130672 (15:55:30 GMT-0400 (EDT))
2018-07-09 19:55:30:695 - [MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: 'Command '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell am instrument -w -e debug false io.appium.espressoserver.test/android.support.test.runner.AndroidJUnitRunner' exited with code 1'; Stderr: 'java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.espressoserver.test/android.support.test.runner.AndroidJUnitRunner} from pid=16287, uid=16287 not allowed because package io.appium.espressoserver.test does not have a signature matching the target com.samsung.android.app.memo
2018-07-09 19:55:30:695 - [MJSONWP]     at android.os.Parcel.readException(Parcel.java:1958)
2018-07-09 19:55:30:696 - [MJSONWP]     at android.os.Parcel.readException(Parcel.java:1904)
2018-07-09 19:55:30:696 - [MJSONWP]     at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5594)
2018-07-09 19:55:30:696 - [MJSONWP]     at com.android.commands.am.Instrument.run(Instrument.java:408)
2018-07-09 19:55:30:696 - [MJSONWP]     at com.android.commands.am.Am.runInstrument(Am.java:232)
2018-07-09 19:55:30:697 - [MJSONWP]     at com.android.commands.am.Am.onRun(Am.java:125)
2018-07-09 19:55:30:697 - [MJSONWP]     at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
2018-07-09 19:55:30:697 - [MJSONWP]     at com.android.commands.am.Am.main(Am.java:95)
2018-07-09 19:55:30:697 - [MJSONWP]     at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
2018-07-09 19:55:30:697 - [MJSONWP]     at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:287)'; Code: '1'
2018-07-09 19:55:30:698 - [MJSONWP]     at ADB.execFunc$ (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:317:13)
2018-07-09 19:55:30:698 - [MJSONWP]     at tryCatch (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
2018-07-09 19:55:30:698 - [MJSONWP]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
2018-07-09 19:55:30:698 - [MJSONWP]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
2018-07-09 19:55:30:698 - [MJSONWP]     at GeneratorFunctionPrototype.invoke (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
2018-07-09 19:55:30:699 - [MJSONWP]     at <anonymous>
2018-07-09 19:55:30:700 - [HTTP] <-- POST /wd/hub/session 500 19622 ms - 1419

io.appium.espressoserver.test does not have a signature matching the target com.samsung.android.app.memo

espresso must be INSIDE your apk (you need re-build apk). link to setup: https://developer.android.com/training/testing/espresso/setup

BUT as far as you are going to test Samsung app - hardly you can do this.

Thanks Aleksei… that is just the app I use to try things out. Unfortunately I don’t like the idea of running a release candidate or release build with espresso in it… so I guess I’ll stick with uiautomator2 for now.

Did you try appium@beta? Also it might be a good idea to reset the device to its default settings to make sure there are no leftovers.

This may help you.

Using Espresso With Appium

You have to uninstall your app firstly to make espresso be identified by your app

1 Like

@ Aleksei. Could you please elaborate more io.appium.espressoserver.test does not have a signature matching the target. am getting the same error. Any help really appreciated.

1 Like

Ask Android dev add Espresso test framework to mobile client.

@Aleksei Could you please help me. My Android dev are using RoboElectric. Still do they need to add decency for Espresso test framework to the mobil client. They are unaware of what should be added. Can you please tell me what are the decency that they need to add?

https://developer.android.com/training/testing/espresso/setup

@Aleksei. Thanks for the immediate reply. I just uninstalled my app in the device then am not getting this issue ’ io.appium.espressoserver.test does not have a signature matching the target .

Then I got the error as ’ Resources$NotFoundException Resource is not a Drawable’ . Then I did these things ’

  • changed all SDK versions in both build.gradle and serverd manifest to match versions in AUT
  • disabled transitive dependencies for espresso-contrib (I guess these dependencies are main cause for this issue)
  • excluded androidx.test.espresso group from transitive dependencies of espresso-web
    Build the espresso Server and replaced the espresso-server debug Build APK

Now the Resource Not Found error has been resolved.
But getting the following error '2019-11-21 05:51:29:490 [Espresso] Installed Espresso Test Server apk ‘/var/folders/qv/0jx6zk2s2sx4h0x4vypksn84zc27mv/T/io.appium.espressoserver.test_1.16.0_bet.thescore.android.debug.apk’ (pkg: ‘io.appium.espressoserver.test’)
2019-11-21 05:51:29:491 [Espresso] Performing cleanup of automation leftovers
2019-11-21 05:51:29:516 [Espresso] No obsolete sessions have been detected (Error: socket hang up)
2019-11-21 05:51:29:516 [Espresso] Starting Espresso Server v1.16.0 with cmd: adb shell am instrument -w -e debug false io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
2019-11-21 05:51:29:516 [ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“84B5T15B03005449”,“shell”,“am”,“instrument”,"-w","-e",“debug”,“false”,“io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner”]
2019-11-21 05:51:36:651 [Espresso] [Instrumentation] [STDOUT] INSTRUMENTATION_RESULT: shortMsg=Process crashed.
2019-11-21 05:51:36:653 [Espresso] [Instrumentation] [STDOUT] INSTRUMENTATION_CODE: 0
2019-11-21 05:51:36:706 [Espresso] Instrumentation process exited with code 0 from signal null
2019-11-21 05:51:59:535 [Espresso] Deleting espresso session
2019-11-21 05:51:59:535 [ADB] Running ‘/usr/local/share/android/sdk/platform-tools/adb -P 5037 -s 84B5T15B03005449 shell am broadcast -a io.appium.settings.animation -n io.appium.settings/.receivers.AnimationSettingReceiver --es setstatus enable’
2019-11-21 05:51:59:646 [ADB] Running ‘/usr/local/share/android/sdk/platform-tools/adb -P 5037 -s 84B5T15B03005449 shell am force-stop bet.thescore.android.debug’
2019-11-21 05:51:59:716 [Logcat] Stopping logcat capture
2019-11-21 05:51:59:721 [ADB] Removing forwarded port socket connection: 54079
2019-11-21 05:51:59:721 [ADB] Running ‘/usr/local/share/android/sdk/platform-tools/adb -P 5037 -s 84B5T15B03005449 forward --remove tcp:54079’
2019-11-21 05:51:59:730 [BaseDriver] Event ‘newSessionStarted’ logged at 1574333519730 (05:51:59 GMT-0500 (Eastern Standard Time))
2019-11-21 05:51:59:730 [W3C] Encountered internal error running command: Error: The process did not start within 30000ms (cmd: ‘/usr/local/share/android/sdk/platform-tools/adb -P 5037 -s 84B5T15B03005449 shell am instrument -w -e debug false io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner’)
2019-11-21 05:51:59:730 [W3C] at Timeout._onTimeout (/usr/local/lib/node_modules/appium/node_modules/teen_process/lib/subprocess.js:197:18)
2019-11-21 05:51:59:730 [W3C] at listOnTimeout (internal/timers.js:531:17)
2019-11-21 05:51:59:730 [W3C] at processTimers (internal/timers.js:475:7)
2019-11-21 05:51:59:767 [HTTP] <-- POST /wd/hub/session 500 54638 ms - 963
2019-11-21 05:51:59:767 [HTTP]
2019-11-21 05:51:59:791 [HTTP] --> GET /wd/hub/status
2019-11-21 05:51:59:791 [HTTP] {}

Also at top of the stack trace having this error '2019-11-21 05:51:25:216 [ADB] Got an error during apksigner execution: Command ‘/usr/local/share/android/sdk/build-tools/29.0.0-rc3/apksigner verify --print-certs /var/folders/qv/0jx6zk2s2sx4h0x4vypksn84zc27mv/T/io.appium.espressoserver.test_1.16.0_bet.thescore.android.debug.apk’ exited with code 1
2019-11-21 05:51:25:217 [ADB] apksigner stderr: DOES NOT VERIFY
2019-11-21 05:51:25:217 [ADB] ERROR: JAR signer CERT.RSA: JAR signature META-INF/CERT.SF indicates the APK is signed using APK Signature Scheme v2 but no such signature was found. Signature stripped?
2019-11-21 05:51:25:217 [ADB] ’

Any help is really appreciated. Can you please help me.
Note:
Android dev didn’t include the espresso dependency.

Sorry. Never used Espresso yet.