Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UiAutomator] Permission denied when taking screen shot. #14

Closed
dino-su opened this issue Mar 25, 2015 · 10 comments
Closed

[UiAutomator] Permission denied when taking screen shot. #14

dino-su opened this issue Mar 25, 2015 · 10 comments

Comments

@dino-su
Copy link

dino-su commented Mar 25, 2015

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

@otw
Copy link
Contributor

otw commented Mar 31, 2015

Thanks for the feedback. Will file a bug on your behalf so we can investigate.

@otw otw closed this as completed Mar 31, 2015
@dino-su
Copy link
Author

dino-su commented Apr 8, 2015

Hi @otw,

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

Thanks,
Dino

@cataglyphis
Copy link

Hi @otw
We use UiAutomator 2.0 to take screenshot, and found this issue again, dependencies as below:

compileSdkVersion 22
buildToolsVersion "25.0.3"
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-annotations:23.1.1'

androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'

Do you have any suggestion to solve this problem, or the higher library has already solved this issue?
Thanks.

@AliceSkilsara
Copy link

I have the same problem
E/UiAutomatorBridge: failed to save screen shot to file
java.io.FileNotFoundException: /sdcard/Pictures/Autotests/1502183344782.png (Permission denied)
with settings
buildToolsVersion = "26.0.0"
supportLibVersion = "25.4.0"
runnerVersion = "1.0.0"
rulesVersion = "1.0.0"
espressoVersion = "3.0.0"
uiautomatorVersion = "2.0.0"

@JerryLiu0821
Copy link

I have the same problem,
did this issue fixed or not?

Thanks

@AliceSkilsara
Copy link

AliceSkilsara commented Dec 5, 2017

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

@gailgou
Copy link

gailgou commented 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

@EmotionalRonan
Copy link

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

I have the same problem

@VidyaSumanKumar
Copy link

do we have a fix for this issue

@brettchabot
Copy link
Collaborator

I'd recommend saving the file via TestStorage. Check out the Screenshotsample for an example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants