[AC-4969] open failed: EACCES (Permission denied)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2017-05-29T13:17:23.000+0000 |
Affected Version/s | Appcelerator Studio 4.5.0 |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Jignesh Kasundra |
Assignee | Shak Hossain |
Created | 2017-05-18T06:08:25.000+0000 |
Updated | 2017-05-29T13:17:23.000+0000 |
Description
I am trying to write/read file into the external storage,
Android 6.0 , on first app launching request permission for external storage not working(request Permission already allowed).
however if I fully close the application and re-launch it then it's work, how can make it work on first run
=================================
[ERROR] : TiFileProxy: (main) [51879,60031] IOException encountered
[ERROR] : TiFileProxy: java.io.FileNotFoundException: /storage/emulated/0/com.example.sample/sample.txt: open failed: EACCES (Permission denied)
[ERROR] : TiFileProxy: at libcore.io.IoBridge.open(IoBridge.java:452)
[ERROR] : TiFileProxy: at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiFile.getOutputStream(TiFile.java:273)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiFile.open(TiFile.java:336)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiFile.write(TiFile.java:460)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:287)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:872)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1095)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:357)
[ERROR] : TiFileProxy: at android.os.Handler.dispatchMessage(Handler.java:98)
[ERROR] : TiFileProxy: at android.os.Looper.loop(Looper.java:148)
[ERROR] : TiFileProxy: at android.app.ActivityThread.main(ActivityThread.java:5417)
[ERROR] : TiFileProxy: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiFileProxy: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[ERROR] : TiFileProxy: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
[ERROR] : TiFileProxy: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
[ERROR] : TiFileProxy: at libcore.io.Posix.open(Native Method)
[ERROR] : TiFileProxy: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
[ERROR] : TiFileProxy: at libcore.io.IoBridge.open(IoBridge.java:438)
[ERROR] : TiFileProxy: ... 16 more
sample code for the above issue (app.js) =============
Hello, This is working for me with Android 6.0.1.device. On first run I am allowing the Camera and Storage permission that pops up right after the app opens. Than when the button is clicked the alert dialog opens with "this is my sample text" alert. From now on clicking on the button shows the alert. If I close the app and reopen, this time there is no permission asked to allowed and clicking on the button shows the alert. If I close the app and remove the permissions for that app from the device application manager. I can open the app and the permission dialog pops up now after app opens. If I allow them, than the button click shows the alert text. I am testing with SDK 6.0.4.GA. Make sure you are allowing the permissions on first run before clicking on the button.
Hello, can you try this with the write permission?
Use this in tiapp.xml
Hi, I have tested following test code with latest SDK 6.0.4.GA on android 6.0.1(HTC one m 8). It's working as expected. On the first run, I am allowing the storage permission that pops up right after the app opens. Then when the button is clicked the alert dialog opens with "this is my sample text" alert. If I close the app and reopen, this time there is no permission asked to allowed and clicking on the button shows the alert.
Test Environment
Hello, I am still facing same issue on first run after tryed with write permission, I am checking this on emulator android version 6.0, not tested on real android device version 6.x
Please test this on device. Let us know the version you are testing.