{ "id": "168954", "key": "AC-5086", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-07-20T18:41:47.000+0000", "created": "2017-07-14T11:25:56.000+0000", "labels": [ "android" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-07-20T18:41:47.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "I am facing the below error while writing/reading the file in external storage\r\nThe external file permission is already allowed\r\n\r\nTested on\r\n\r\nTitanium SDK 6.1.0\r\nEmulator - Android 6.0 (API 23)\r\n\r\nPlease also check the shared image of emulator\r\n\r\n==============================================\r\n\r\n\r\n{code:java}\r\nTiFileProxy: (main) [44314,50797] IOException encountered\r\n[ERROR] : TiFileProxy: java.io.FileNotFoundException: /storage/emulated/0/com.info.external/sample.txt: open failed: EACCES (Permission denied)\r\n[ERROR] : TiFileProxy: \tat libcore.io.IoBridge.open(IoBridge.java:452)\r\n[ERROR] : TiFileProxy: \tat java.io.FileOutputStream.(FileOutputStream.java:87)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.io.TiFile.getOutputStream(TiFile.java:289)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.io.TiFile.open(TiFile.java:352)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.io.TiFile.write(TiFile.java:476)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:305)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:872)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1095)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:360)\r\n[ERROR] : TiFileProxy: \tat android.os.Handler.dispatchMessage(Handler.java:98)\r\n[ERROR] : TiFileProxy: \tat android.os.Looper.loop(Looper.java:148)\r\n[ERROR] : TiFileProxy: \tat android.app.ActivityThread.main(ActivityThread.java:5417)\r\n[ERROR] : TiFileProxy: \tat java.lang.reflect.Method.invoke(Native Method)\r\n[ERROR] : TiFileProxy: \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\r\n[ERROR] : TiFileProxy: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\r\n[ERROR] : TiFileProxy: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)\r\n{code}\r\n\r\n\r\n\r\n\r\n=======================================\r\napp.js code\r\n==========================================\r\n\r\n\r\n{code:java}\r\n\r\nvar storePermission = \"android.permission.WRITE_EXTERNAL_STORAGE\";\r\n \r\nvar storagePermission = \"android.permission.READ_EXTERNAL_STORAGE\";\r\n \r\nvar hasStorePermission = Ti.Android.hasPermission(storePermission);\r\n \r\nvar hasStoragePermission = Ti.Android.hasPermission(storagePermission);\r\n \r\nvar permissionsToRequest = [];\r\n \r\nvar win = Ti.UI.createWindow({\r\n \r\n title : 'mywin',\r\n \r\n backgroundColor : '#fff',\r\n \r\n width : Ti.UI.FILL,\r\n \r\n height : Ti.UI.FILL\r\n \r\n});\r\n \r\nwin.open();\r\n\r\nwin.addEventListener('open',function(){\r\n\r\n\t\tif (!hasStorePermission) {\r\n\t\t \r\n\t\t permissionsToRequest.push(storePermission);\r\n\t\t Ti.API.info(\"PUSHED 1.WRITE_EXTERNAL_STORAGE\");\r\n\t\t\r\n\t\t}\r\n\t\t \r\n\t\tif (!hasStoragePermission) {\r\n\t\t \r\n\t\t permissionsToRequest.push(storagePermission);\r\n\t\t Ti.API.info(\"PUSHED... 2.READ_EXTERNAL_STORAGE\");\r\n\t\t \r\n\t\t}\r\n\t\t \r\n\t\tif (permissionsToRequest.length > 0) {\r\n\t\t \r\n\t\t Ti.Android.requestPermissions(permissionsToRequest, function(e) {\r\n\t\t \t\t\r\n\t\t \t\tTi.API.info('Requesting Permission', e);\r\n\t\t \t\t\r\n\t\t if (e.success) {\r\n\t\t \r\n\t\t Ti.API.info(\"SUCCESS\");\r\n\t\t \r\n\t\t } else {\r\n\t\t \r\n\t\t Ti.API.info(\"ERROR: \" + e.error);\r\n\t\t \r\n\t\t }\r\n\t\t \r\n\t\t });\r\n\t\t \r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n});\r\n \r\n \r\nvar btn1 = Ti.UI.createButton({\r\n \r\n title : 'Write',\r\n \r\n top : 60\r\n \r\n});\r\n \r\nwin.add(btn1);\r\n \r\n \r\n \r\nbtn1.addEventListener('click', function() {\r\n \r\n \t\r\n \tif(Ti.Filesystem.hasStoragePermissions()){\r\n \t\t\r\n \t\tvar localPath = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory).nativePath;\r\n \r\n \t\tvar sampletxtvar = Ti.Filesystem.getFile(localPath, \"sample.txt\");\r\n \r\n \t\tsampletxtvar.write(\"this is my sample text\");\r\n \r\n \t\talert(\"\\n Storage Permission :: \" + Ti.Filesystem.hasStoragePermissions() + \"\\n File Writable :: \"+sampletxtvar.writable +\"\\n File Content :: \" +sampletxtvar.read().text);\r\n \t\t\r\n \t}\r\n});\r\n{code}\r\n\r\n\r\n\r\n==========================\r\ntiapp.xml\r\n==========================\r\n\r\n{code:java}\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n{code}\r\n\r\n", "attachment": [ { "id": "62885", "filename": "Screen Shot 2017-07-14.png", "author": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-07-14T11:18:45.000+0000", "size": 51067, "mimeType": "image/png" } ], "flagged": false, "summary": "Android 6.0 : open failed: EACCES (Permission denied) , Even storagePermission is true on emulator", "creator": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Android", "comment": { "comments": [ { "id": "424165", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Can you please try it on real device with external storage? ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-07-14T19:41:23.000+0000", "updated": "2017-07-14T19:41:23.000+0000" }, { "id": "424225", "author": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello Sharif,\r\n\r\nthanks, I have tested on real device and it's working fine.\r\nplease close this issue\r\n", "updateAuthor": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-07-17T13:59:54.000+0000", "updated": "2017-07-17T13:59:54.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }