facebook / screenshot-tests-for-android

Generate fast deterministic screenshots during Android instrumentation tests
http://facebook.github.io/screenshot-tests-for-android
Apache License 2.0
1.74k stars 229 forks source link

java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Operation not permitted #278

Closed leonlujs closed 3 years ago

leonlujs commented 3 years ago

I am trying this determinic screenshot library but always got Operation not permitted error when calling Screenshot.snapActivity(mActivity).setName(name).record(). Looks like I was able to create directory but not able to save the screenshot. Has anyone seen the same error? I already put in AndroidManifest, and my emulator is Pixel XL API 30.

java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Operation not permitted at com.facebook.testing.screenshot.internal.ScreenshotImpl.runCallableOnUiThread(ScreenshotImpl.java:345) at com.facebook.testing.screenshot.internal.ScreenshotImpl.storeBitmap(ScreenshotImpl.java:166) at com.facebook.testing.screenshot.internal.ScreenshotImpl.record(ScreenshotImpl.java:270) at com.facebook.testing.screenshot.internal.RecordBuilderImpl.record(RecordBuilderImpl.java:152) ... Caused by: java.lang.RuntimeException: java.io.IOException: Operation not permitted at com.facebook.testing.screenshot.internal.ScreenshotImpl.storeBitmap(ScreenshotImpl.java:199) at com.facebook.testing.screenshot.internal.ScreenshotImpl.access$000(ScreenshotImpl.java:50) at com.facebook.testing.screenshot.internal.ScreenshotImpl$2.call(ScreenshotImpl.java:170) at com.facebook.testing.screenshot.internal.ScreenshotImpl$2.call(ScreenshotImpl.java:167) at com.facebook.testing.screenshot.internal.ScreenshotImpl$3.run(ScreenshotImpl.java:327) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Caused by: java.io.IOException: Operation not permitted at java.io.UnixFileSystem.createFileExclusively0(Native Method) at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:317) at java.io.File.createNewFile(File.java:1008) at com.facebook.testing.screenshot.internal.AlbumImpl.getOrCreateZipOutputStream(AlbumImpl.java:67) at com.facebook.testing.screenshot.internal.AlbumImpl.writeBitmap(AlbumImpl.java:183) at com.facebook.testing.screenshot.internal.ScreenshotImpl.drawTile(ScreenshotImpl.java:235) at com.facebook.testing.screenshot.internal.ScreenshotImpl.storeBitmap(ScreenshotImpl.java:195) ... 11 more

leonlujs commented 3 years ago

This issue can be fixed with the same solution of sdcard not accessible #256

oradkovsky commented 3 years ago

@leonlujs have you verified it? It cannot be fixed by mentioned solution assuming android 11.