appium-espresso-driver
appium-espresso-driver copied to clipboard
Not able to launch app when using Espresso with Appium v1.15.1
I have a very simple test app that just launches my Android app - if I set the "automationName" to "UiAutomator2" then my app is launched fine but if I change this to "Espresso" then nothing is launched.
In the Console, it mentions 1 test has ran and 1 test has passed but the app is not launched at all - this means that I am not given any errors so I don't know why my app isn't launching when using Espresso.
This is my code:
private String APP = "https://github.com/cloudgrey-io/the-app/releases/download/v1.8.1/TheApp-v1.8.1.apk";
static AppiumDriver driver;
@BeforeTest
public void setup() {
try {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformName", "Android");
caps.setCapability("deviceName", "Android Emulator");
caps.setCapability("automationName", "Espresso");
caps.setCapability("app", APP);
driver = new AppiumDriver(new URL("http://localhost:4723/wd/hub"), caps);
}catch(Exception e) {
System.out.println("Exception is :"+e.getCause());
System.out.println("Message is :"+e.getMessage());
e.printStackTrace();
}
}
I'm not exactly sure of the app being downloaded here, this was just the example used in the online tutorial I was following in the hope of fixing my issue.
The app is launched if I use "UiAutomator2" but fails to launch when using "Espresso".
Is this a bug, or I am just missing something obvious?
Please attach the full log. Espresso strongly depends on the test under app rather than UIA2, so dependency issues such as https://github.com/appium/appium-espresso-driver/issues/449 could happen, for example.
After investigating the logs, it looks like I might have a couple of issues. I believe the reason I can't run the .apk mentioned above is because for some reason my test script seems to be referencing the app package for my own app (even though I can't find a reference to this anywhere in the code) - I will have to speak to my companies Test Department (as they original wrote the script I'm testing) to see if they know why it is referencing a different app.
When updating the "DesiredCapabilities" to my own app, I still get the same problem (ie. the app launches when using "UiAutomator2" but fails when using "Espresso").
Here is the log:
[RemoteTestNG] detected TestNG version 7.0.0
Exception is :java.lang.reflect.InvocationTargetException
Message is :Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner} from pid=22513, uid=22513 not allowed because package io.appium.espressoserver.test does not have a signature matching the target com.dhlparcel.mydrive
at android.os.Parcel.readException(Parcel.java:2013)
at android.os.Parcel.readException(Parcel.java:1959)
at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5093)
at com.android.commands.am.Instrument.run(Instrument.java:419)
at com.android.commands.am.Am.runInstrument(Am.java:187)
at com.android.commands.am.Am.onRun(Am.java:80)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
at com.android.commands.am.Am.main(Am.java:50)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:285)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '51IDLT84AB17', ip: '10.210.104.47', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner} from pid=22513, uid=22513 not allowed because package io.appium.espressoserver.test does not have a signature matching the target com.dhlparcel.mydrive
at android.os.Parcel.readException(Parcel.java:2013)
at android.os.Parcel.readException(Parcel.java:1959)
at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5093)
at com.android.commands.am.Instrument.run(Instrument.java:419)
at com.android.commands.am.Am.runInstrument(Am.java:187)
at com.android.commands.am.Am.onRun(Am.java:80)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
at com.android.commands.am.Am.main(Am.java:50)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:285)
at getResponseForW3CError (C:\Users\kevinroughton\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)
at asyncHandler (C:\Users\kevinroughton\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:388:37)
at process._tickCallback (internal/process/next_tick.js:68:7)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '51IDLT84AB17', ip: '10.210.104.47', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: AppiumDriver
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner} from pid=22513, uid=22513 not allowed because package io.appium.espressoserver.test does not have a signature matching the target com.dhlparcel.mydrive
at android.os.Parcel.readException(Parcel.java:2013)
at android.os.Parcel.readException(Parcel.java:1959)
at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5093)
at com.android.commands.am.Instrument.run(Instrument.java:419)
at com.android.commands.am.Am.runInstrument(Am.java:187)
at com.android.commands.am.Am.onRun(Am.java:80)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
at com.android.commands.am.Am.main(Am.java:50)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:285)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '51IDLT84AB17', ip: '10.210.104.47', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner} from pid=22513, uid=22513 not allowed because package io.appium.espressoserver.test does not have a signature matching the target com.dhlparcel.mydrive
at android.os.Parcel.readException(Parcel.java:2013)
at android.os.Parcel.readException(Parcel.java:1959)
at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5093)
at com.android.commands.am.Instrument.run(Instrument.java:419)
at com.android.commands.am.Am.runInstrument(Am.java:187)
at com.android.commands.am.Am.onRun(Am.java:80)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
at com.android.commands.am.Am.main(Am.java:50)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:285)
at getResponseForW3CError (C:\Users\kevinroughton\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)
at asyncHandler (C:\Users\kevinroughton\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:388:37)
at process._tickCallback (internal/process/next_tick.js:68:7)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '51IDLT84AB17', ip: '10.210.104.47', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: AppiumDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.
=============================================== Default test Tests run: 1, Failures: 0, Skips: 0
=============================================== Default suite Total tests run: 1, Passes: 1, Failures: 0, Skips: 0
I've tried googling the errors in the log, and I found a link that mentions Espresso dependencies are needed to be built in the .apk for automated testing to be allowed. The following page was suggested as a means of setting this up: https://developer.android.com/training/testing/espresso/setup
Now my problem with this, is that my app is not written in native Android - my app is written in Xamarin Forms. The article mentions updating the build.gradle file, but as my app is written in Xamarin Forms I do not have a build.gradle file to update.
Does this sound like this could be my problem, and if so, do you know how I can add the Espresso dependencies to my Xamarin Forms app?
I guess the test app failed to re-sign with Appium's developer sign. Espresso and the app under test should have the same signature. espresso-driver tries to re-sing the app under test with Appium's one, but it fails by some reason, such security exception happens.
I assume you can find a waring/error log about apksigner in your log if the re-sign action failed
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.espressoserver.test/androidx.test.runner.AndroidJUnitRunner} from pid=22513, uid=22513 not allowed because package io.appium.espressoserver.test does not have a signature matching the target com.dhlparcel.mydrive
at android.os.Parcel.readException(Parcel.java:2013)
at android.os.Parcel.readException(Parcel.java:1959)
at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5093)
at com.android.commands.am.Instrument.run(Instrument.java:419)
at com.android.commands.am.Am.runInstrument(Am.java:187)
at com.android.commands.am.Am.onRun(Am.java:80)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
at com.android.commands.am.Am.main(Am.java:50)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:285)
at getResponseForW3CError (C:\Users\kevinroughton\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)
at asyncHandler (C:\Users\kevinroughton\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:388:37)
at process._tickCallback (internal/process/next_tick.js:68:7)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '51IDLT84AB17', ip: '10.210.104.47', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: AppiumDriver
Hi, i want to ask about how to use this appium with espresso driver. Do we have to add espresso dependencies in the android application?
Basically http://appium.io/docs/en/drivers/android-espresso/ is to start with the espresso driver. For other general questions, please ask in https://discuss.appium.io/ first