DanielHsu
DanielHsu

Reputation: 115

Android can't run UI Testing with "uiautomator: permission denied" error message

My environment is:

Android phone : HTC Desired Z

Android version: 2.3.3

when i use the web method:http://developer.android.com/tools/testing/testing_ui.html

run the UI Testing with the command "adb shell uiautomator runtest LaunchSettings.jar -c com.uia.example.my.LaunchSettings"

it show the error message "uiautomator: permission denied" .

Anyone friend that tell me to the reason of error???

thank!~

Upvotes: 2

Views: 5907

Answers (1)

JulianHarty
JulianHarty

Reputation: 3286

Can you double-check a couple of things please?

  • Which version of Android are you deploying the tests to? UIAutomator is only available on devices with API level 16 or later (Android 4.1 and 4.2) so it should not be available on a 2.3.3 device. Run the following command on a command-line to get the version of Android installed: adb shell grep ro.build.version.sdk= system/build.prop the result should be similar to ro.build.version.sdk=17 Here is a StackOverflow article on getting the version of Android using adb shell Getting Android SDK version of a device from command line
  • What is the precise error message do you get when you run the adb shell uiautomator runtest LaunchSettings.jar -c com.uia.example.my.LaunchSettings command?

I tested with an AVD running 2.3.3 (API level 10) and ran the commands to build, deploy and then run the UI Automator tests from the Android example from http://developer.android.com/tools/testing/testing_ui.html The error message I get is different from the one you report: I get uiautomator: not found rather than permission denied.

As a suggestion, try to run uiautomatorviewer from the command line when your device is connected (which you can check with the adb devices command - your device's serial number should be listed). When I run uiautomatorviewer against the AVD with 2.3.3 when I try to get a screen snapshot it tells me explicitly "UI Automator requires a device with API Level 16"

So in summary, AFAIK you need uiautomator with a device running API level 16 or later. In practice, UI Automator seems to be problematic on API level 16 (Android 4.1) and works best with devices running 4.2.1 of Android (API level 17).

Upvotes: 2

Related Questions