3

Reference Links: Link1, Robotium Link2

as we know that from Robotium Link2, we can run robotium test run from android code.

Now lets talk about uiautomator

i already done following steps manually from Link1

adb push bin/AutomatedTests.jar /data/local/tmp/

Question : How to run bellow line from "Android Activity Code" :

adb shell uiautomator runtest /data/local/tmp/AutomatedTests.jar -c com.example.tests.SimpleTest

Case 1:

i tried this code: Code Link, with arguments as bellow

String[] strCmdArgsUiTesting = 
"/system/bin/uiautomator runtest UiTestingExample.jar -c com.intel.vishal.uitestingexample.LaunchBasemarkES2Taiji".split(" ");

Error comes :

INSTRUMENTATION_RESULT: longMsg=Permission Denial: 
Do not have permission in call getContentProviderExternal() 
from pid=2691, uid=10082 
requires android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY

i added this permission to AndroidManifest.xml as bellow

<uses-permission android:name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY"/>

but same error comes again. this permission is not working in android activity...

How to solve this error ?

Please Note :- i am using Android 4.2.2

Community
  • 1
  • 1
VISHAL VIRADIA
  • 1,388
  • 1
  • 15
  • 34
  • 1
    were you able to solve this problem? I'm stuck on this as well. – Goran Horia Mihail Nov 10 '14 at 08:33
  • Were you able to do this? I'm stuck on the same thing. I'm stuck on a rooted device as well. :-( – Ambi Aug 05 '16 at 05:25
  • i am not able to do this, as android application does not have permission to access "uiautomator runtest". i have signed my android test application & using robotium i am accessing UI of my test app & that will do automation for only one application. [ not complete system ]. – VISHAL VIRADIA Aug 05 '16 at 09:17

2 Answers2

3

I do believe that your phone needs to be rooted in order to call any console command from the app's Java code...

VladimirVip
  • 384
  • 3
  • 13
2

Check this link to see how to run a command from android code: Android run bash command in app

Now, you want to execute

uiautomator runtest /data/local/tmp/AutomatedTests.jar -c com.example.tests.SimpleTest

instead of

adb shell uiautomator runtest /data/local/tmp/AutomatedTests.jar -c com.example.tests.SimpleTest
Community
  • 1
  • 1
Aman Gautam
  • 3,549
  • 2
  • 21
  • 25
  • i tried to execute from this link "http://stackoverflow.com/questions/15607710/how-to-top-m-10-n-1-command-output-save-to-string-in-android-code", but error is "INSTRUMENTATION_RESULT: longMsg=Permission Denial: Do not have permission in call getContentProviderExternal() from pid=2691, uid=10082 requires android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY", how to solve this ? – VISHAL VIRADIA Aug 13 '13 at 09:21
  • see this link for some information, "http://stackoverflow.com/questions/18137176/android-workaround-the-access-content-providers-externally-permission" about my error – VISHAL VIRADIA Aug 13 '13 at 09:21
  • if you are getting an error related to permission, simply add tag in the manifest file and use the permission android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY – Aman Gautam Aug 13 '13 at 09:33
  • i already added same permission, but same error comes again. this permission is not working. – VISHAL VIRADIA Aug 13 '13 at 09:35
  • newers android newest permission and newer protection.... simple solutions : root :: danger. – gumuruh Apr 16 '23 at 08:17