Appium 1.8.1 trying to get espresso running


#1

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

#2

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.


#3

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.


#4

Did you try [email protected]? Also it might be a good idea to reset the device to its default settings to make sure there are no leftovers.


#5

This may help you.

Using Espresso With Appium


#6

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