question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[UiAutomator] Permission denied when taking screen shot.

See original GitHub issue

Hi,

I presume that with UiAutomator 2.0 the only way to invoke UI testing is using gradle ($ ./gradlew connectedCheck), however it seems like it doesn’t have enough privilege to create new file.

03-25 14:48:37.359: E/UiAutomatorBridge(13955): failed to save screen shot to file
03-25 14:48:37.359: E/UiAutomatorBridge(13955): java.io.FileNotFoundException: /data/local/tmp/uiautomator.png: open failed: EACCES (Permission denied)

But if you create the file via adb shell ($ adb shell touch /data/local/tmp/uiautomator.png) first then everything will works fine.

Could you please have a look on the gradle permission issue ?

Thanks, Dino

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
gailgoucommented, Oct 15, 2019

Hi. I found a decision.

  1. You should add permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  1. Input in console

adb shell pm grant com.example.android.testing.uiautomator.your_app android.permission.READ_EXTERNAL_STORAGE

adb shell pm grant com.example.android.testing.uiautomator.your_app android.permission.WRITE_EXTERNAL_STORAGE 3. And now you can take a screenshot

all above i have done .but can’t slove the problem

2reactions
dino-sucommented, Apr 8, 2015

Hi @otw,

Can you let me know where to track the permission issue ?

Thanks, Dino

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting permission denied error while taking device ...
While i am clicking on device screenshot option in UIAUTOMATOR getting this error Error while obtaining UI hierarchy XML file: com.android.
Read more >
Handling Android runtime permissions in UI tests - Medium
Next, we need to either grant or deny this permission by using UiAutomator to interact with the permissions dialog.
Read more >
Taking a screenshot using UiAutomator framework is broken ...
Issue: I'm currently unable to capture screenshots when tests fail using the UiAutomator framework's takeScreenshot method: UiDevice.
Read more >
Permissions on Android - Android Developers
A pop-up dialog that contains 2 options: allow and deny. Figure 3. The system permission prompt that appears when your app requests a...
Read more >
UIAutomatorViewer Tutorial: Inspect Elements On Android
#2) Your device is not in an idle state: For the screen which is not static, like the video is playing or any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found