Unable to run test with Espresso Driver [ERROR: JAR signer CERT.RSA: JAR signature META-INF/CERT.SF]


For Android I always used UiAutomator2 driver, but now I want to try the performance of Espresso, so I set the capabilities:

capabilities.setCapability(“automationName”, “Espresso”);
capabilities.setCapability(“forceEspressoRebuild”, true);

I also make sure I have all the necessary dependencies in the Android project to include Espresso in the .apk.

When I run the test, I get the following error in the log:

Installing Espresso Test Server apk from the target device (path: ‘/var/folders/rw/dg1m6r552bx2pfpk5m7__7z53jnw6h/T/io.appium.espressoserver.test_1.7.1_com.xxx.app.staging.apk’)
2019-04-12 10:35:29:524 [Espresso] Installed Espresso Test Server apk ‘/var/folders/rw/dg1m6r552bx2pfpk5m7__7z53jnw6h/T/io.appium.espressoserver.test_1.7.1_com.xxx.app.staging.apk’ (pkg: ‘io.appium.espressoserver.test’)
2019-04-12 10:35:29:524 [Espresso] Adjusted appActivity to fully qualified version: ‘com.xxx.app.staging.com.xxx.app.intro.IntroActivity’
2019-04-12 10:35:29:524 [Espresso] Starting Espresso Server v1.7.1 with cmd: adb shell am instrument -w -e debug false io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner
2019-04-12 10:35:35:448 [Espresso] Waiting for Espresso to be online…
2019-04-12 10:35:36:569 [WD Proxy] Got an unexpected response: {“id”:“a02140d4-4072-4cd3-80a6-0c6a72192fc5”,“sessionId”:null,“status”:33,“value”:"io.appium.espressoserver.lib.handlers.exceptions.SessionNotCreatedException: java.lang.RuntimeException: Could not launch activity\n\tat io.appium.espressoserver.lib.handlers.CreateSession.handle(CreateSession.java…
2019-04-12 10:35:36:689 [Espresso] Restoring hidden api policy to the device default configuration
2019-04-12 10:35:36:712 [Espresso] Instrumentation process exited with code 0 from signal null
2019-04-12 10:38:25:313 [HTTP] →


[AndroidDriver] Java version is: 1.8.0_66
2019-04-12 10:38:25:666 [AndroidDriver] Retrieving device list
2019-04-12 10:38:25:679 [AndroidDriver] Using device: UBV7N18323012684
2019-04-12 10:38:25:728 [Espresso] Relaxing hidden api policy
2019-04-12 10:38:28:379 [ADB] Package name: ‘com.xxx.app.staging’
2019-04-12 10:38:28:379 [ADB] Main activity name: ‘com.xxx.app.intro.IntroActivity’
2019-04-12 10:38:30:038 [AndroidDriver] Screen already unlocked, doing nothing
2019-04-12 10:38:47:571 [Espresso] Forcing Espresso server rebuild because of changed application package
2019-04-12 10:38:47:572 [Espresso] Repackaging espresso server for: ‘com.xxx.app.staging’
2019-04-12 10:38:47:574 [Espresso] Creating new manifest: ‘/var/folders/rw/dg1m6r552bx2pfpk5m7__7z53jnw6h/T/AndroidManifest.xml’
2019-04-12 10:38:47:799 [Espresso] Repackaged espresso server ready: ‘/var/folders/rw/dg1m6r552bx2pfpk5m7__7z53jnw6h/T/io.appium.espressoserver.test_1.7.1_com.xxx.app.staging.apk’
2019-04-12 10:38:48:285 [ADB] Got an error during apksigner execution: Command ‘/Users/zigas/Library/Android/sdk/build-tools/28.0.3/apksigner verify --print-certs /var/folders/rw/dg1m6r552bx2pfpk5m7__7z53jnw6h/T/io.appium.espressoserver.test_1.7.1_com.xxx.app.staging.apk’ exited with code 1
2019-04-12 10:38:48:285 [ADB] apksigner stderr: DOES NOT VERIFY
2019-04-12 10:38:48:285 [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?

I have checked the repackaged Manifest.xml file and I can see it does not include the appPackage that is searching for.

What seems to be the problem here?

I tried the same on Appium v1.12.1 and beta version (v1.13.0-beta.2).

Try to set the buildToolsVersion cap to a valid build tools version, which is lower that the most recent one installed on your machine (only present in the recent beta). I was observing an issue where some usual binaries were replaced/changed in the latest beta of build tools, which was causing unexpected problems. See https://github.com/appium/appium/issues/12442 fore more details.

Awesome, I will try this and let you know of the results.