Selendroid server can't start on device: Permission Denial: starting instrumentation

1.1k views Asked by At

Looking at automating our android device testing using Selendroid. As I'm just at the research phase I'm using the selendroid-test-app downloaded from their website.

I recently got a new machine. My code and setup worked just fine on the previous one.

My JAVA_HOME is set to: C:\Program Files\Java\jdk1.8.0_45 My ANDROID_HOME is C:\Program Files (x86)\Android\android-sdk I start up the selendroid standalone by running the following command in a console in a local directory:

java -jar selendroid-standalone-0.15.0-with-dependencies.jar -app selendroid-test-app-0.15.0.apk

This signs the apk fine:

INFO: Executing shell command: C:\Program Files\Java\jdk1.8.0_45\bin\jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -signedjar c:\SeleniumDrivers\resigned-selendroid-test-app-0.15.0.apk -storepass android -keystore C:\Users\rekab\.android\debug.keystore c:\SeleniumDrivers\selendroid-test-app-0.15.0.apk androiddebugkey
Jun 12, 2015 8:16:14 AM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
jar signed.

Then I start the tests from Visual Studio (C#):

DesiredCapabilities caps = DesiredCapabilities.Android();
caps.SetCapability("browserName", "selendroid");
caps.SetCapability("aut", "io.selendroid.testapp:0.15.0");  

TouchCapableRemoteWebDriver driver = new TouchCapableRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), caps);

TouchCapableRemoteWebDriver is a wrapper around RemoteWebDriver implementing IHasTouchScreen.

When the driver is getting created, selendroid-test-app gets installed on the phone fine:

INFO: Executing shell command: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s FA34HW903620 install -r c:\SeleniumDrivers\resigned-selendroid-test-app-0.15.0.apk
Jun 12, 2015 8:17:52 AM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
pkg: /data/local/tmp/resigned-selendroid-test-app-0.15.0.apk
Success
rm failed for -f, No such file or directory
3560 KB/s (511417 bytes in 0.140s)
<--
Jun 12, 2015 8:17:53 AM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s FA34HW903620 shell pm list packages io.selendroid.io.selendroid.testapp
Jun 12, 2015 8:17:54 AM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
package:io.selendroid.io.selendroid.testapp
<--

However, when it gets to starting the instrumentation I get an exception:

INFO: Executing shell command: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s FA34HW903620 shell am instrument -e main_activity io.selendroid.testapp.HomeScreenActivity -e server_port 8080 io.selendroid.io.selendroid.testapp/io.selendroid.server.ServerInstrumentation
Jun 12, 2015 8:17:55 AM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.selendroid.io.selendroid.testapp/io.selendroid.server.ServerInstrumentation} from pid=26099, uid=26099 not allowed because package io.selendroid.io.selendroid.testapp does not have a signature matching the target io.selendroid.testapp
        at android.os.Parcel.readException(Parcel.java:1430)
        at android.os.Parcel.readException(Parcel.java:1384)
        at android.app.ActivityManagerProxy.startInstrumentation(ActivityManagerNative.java:2839)
        at com.android.commands.am.Am.runInstrument(Am.java:615)
        at com.android.commands.am.Am.run(Am.java:118)
        at com.android.commands.am.Am.main(Am.java:81)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:257)
        at dalvik.system.NativeStart.main(Native Method)
<--

Obviously, the test can't start. What's going wrong? Even with the new machine this was working up till the point when I uninstalled the app from the phone and ran the test again. It now gets re-installed but the server on the phone can't start?

Thanks for any help!

1

There are 1 answers

0
lopisan On

The problem is, that on your phone is left application selendroid signed with key from the old machine, whereas the tested app is signed with key generated on new machine and these two doesn't match.

Solution: Uninstall both apps selendroid and tested app from your phone and selendroid will install them both signed with the same key.