{ "id": "167789", "key": "AC-4969", "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": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2017-05-29T13:17:23.000+0000", "created": "2017-05-18T06:08:25.000+0000", "labels": [], "versions": [ { "id": "17038", "name": "Appcelerator Studio 4.5.0", "archived": false, "released": false } ], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-05-29T13:17:23.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": "\r\nI am trying to write/read file into the external storage,\r\n \r\nAndroid 6.0 , on first app launching request permission for external storage not working(request Permission already allowed). \r\n\r\nhowever if I fully close the application and re-launch it then it's work, how can make it work on first run\r\n\r\n=================================\r\n\r\n\r\n{code:java}\r\n[ERROR] : TiFileProxy: (main) [51879,60031] IOException encountered\r\n[ERROR] : TiFileProxy: java.io.FileNotFoundException: /storage/emulated/0/com.example.sample/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:273)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.io.TiFile.open(TiFile.java:336)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.io.TiFile.write(TiFile.java:460)\r\n[ERROR] : TiFileProxy: \tat org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:287)\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:357)\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[ERROR] : TiFileProxy: \tat libcore.io.Posix.open(Native Method)\r\n[ERROR] : TiFileProxy: \tat libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)\r\n[ERROR] : TiFileProxy: \tat libcore.io.IoBridge.open(IoBridge.java:438)\r\n[ERROR] : TiFileProxy: \t... 16 more\r\n{code}", "attachment": [], "flagged": false, "summary": "open failed: EACCES (Permission denied)", "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": "OSX , Android 6.0 emulator , Titanium SDK 6.0.4 ", "comment": { "comments": [ { "id": "419928", "author": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "sample code for the above issue (app.js)\r\n=============\r\n\r\n{code:java}\r\n\r\nvar cameraPermission = \"android.permission.CAMERA\";\r\n \r\nvar storagePermission = \"android.permission.READ_EXTERNAL_STORAGE\";\r\n \r\nvar hasCameraPermission = Ti.Android.hasPermission(cameraPermission);\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\nif (!hasCameraPermission) {\r\n \r\n permissionsToRequest.push(cameraPermission);\r\n \r\n}\r\n \r\nif (!hasStoragePermission) {\r\n \r\n permissionsToRequest.push(storagePermission);\r\n \r\n}\r\n \r\nif (permissionsToRequest.length > 0) {\r\n \r\n Ti.Android.requestPermissions(permissionsToRequest, function(e) {\r\n \r\n if (e.success) {\r\n \r\n Ti.API.info(\"SUCCESS\");\r\n \r\n } else {\r\n \r\n Ti.API.info(\"ERROR: \" + e.error);\r\n \r\n }\r\n \r\n });\r\n \r\n}\r\n \r\nvar btn1 = Ti.UI.createButton({\r\n \r\n title : 'Write',\r\n top : 60\r\n \r\n});\r\nwin.add(btn1);\r\n \r\nbtn1.addEventListener('click', function() {\r\n var localPath = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory).nativePath;\r\n \r\n var sampletxtvar = Ti.Filesystem.getFile(localPath, \"sample.txt\");\r\n \r\n sampletxtvar.write(\"this is my sample text\");\r\n \r\n alert(sampletxtvar.read().text);\r\n \r\n}); \r\n{code}", "updateAuthor": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-05-18T06:10:50.000+0000", "updated": "2017-05-18T06:10:50.000+0000" }, { "id": "419941", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "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. ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-05-18T14:07:51.000+0000", "updated": "2017-05-18T14:07:51.000+0000" }, { "id": "419950", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, can you try this with the write permission?\r\n{code}\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\nif (!hasStorePermission) {\r\n\r\n permissionsToRequest.push(storePermission);\r\n\r\n}\r\n\r\nif (!hasStoragePermission) {\r\n\r\n permissionsToRequest.push(storagePermission);\r\n\r\n}\r\n\r\nif (permissionsToRequest.length > 0) {\r\n\r\n Ti.Android.requestPermissions(permissionsToRequest, function(e) {\r\n\r\n if (e.success) {\r\n\r\n Ti.API.info(\"SUCCESS\");\r\n\r\n } else {\r\n\r\n Ti.API.info(\"ERROR: \" + e.error);\r\n\r\n }\r\n\r\n });\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 var localPath = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory).nativePath;\r\n\r\n var sampletxtvar = Ti.Filesystem.getFile(localPath, \"sample.txt\");\r\n\r\n sampletxtvar.write(\"this is my sample text\");\r\n\r\n alert(sampletxtvar.read().text);\r\n\r\n\r\n});\r\n{code}\r\n\r\nUse this in tiapp.xml \r\n\r\n{code}\r\n\r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n{code}\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-05-18T15:36:06.000+0000", "updated": "2017-05-18T15:36:06.000+0000" }, { "id": "419954", "author": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "body": "Hi,\r\nI 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.\r\n{code}\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\nif (!hasStorePermission) {\r\n \r\n permissionsToRequest.push(storePermission);\r\n \r\n}\r\n \r\nif (!hasStoragePermission) {\r\n \r\n permissionsToRequest.push(storagePermission);\r\n \r\n}\r\n \r\nif (permissionsToRequest.length > 0) {\r\n \r\n Ti.Android.requestPermissions(permissionsToRequest, function(e) {\r\n \r\n if (e.success) {\r\n \r\n Ti.API.info(\"SUCCESS\");\r\n \r\n } else {\r\n \r\n Ti.API.info(\"ERROR: \" + e.error);\r\n \r\n }\r\n \r\n });\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 var localPath = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory).nativePath;\r\n \r\n var sampletxtvar = Ti.Filesystem.getFile(localPath, \"sample.txt\");\r\n \r\n sampletxtvar.write(\"this is my sample text\");\r\n \r\n alert(sampletxtvar.read().text);\r\n \r\n \r\n});\r\n{code}\r\n\r\nTest Environment \r\n{code}\r\nAppcelerator Command-Line Interface, version 6.2.1\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.11.6\r\n Architecture = 64bit\r\n # CPUs = 4\r\n Memory = 8589934592\r\nNode.js\r\n Node.js Version = 4.4.4\r\n npm Version = 2.15.1\r\nTitanium CLI\r\n CLI Version = 5.0.13\r\nTitanium SDK\r\n SDK Version = 6.0.4.GA\r\n SDK Path = /Users/Raju/Library/Application Support/Titanium/mobilesdk/osx/6.0.4.GA\r\n Target Platform = android\r\n{code}", "updateAuthor": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "created": "2017-05-18T17:00:06.000+0000", "updated": "2017-05-18T17:00:06.000+0000" }, { "id": "420029", "author": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello,\r\n\r\nI am still facing same issue on first run after tryed with write permission, I am checking this on emulator android version 6.0, \r\nnot tested on real android device version 6.x", "updateAuthor": { "name": "jignesh.igp", "key": "jignesh.igp", "displayName": "Jignesh Kasundra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-05-19T13:29:54.000+0000", "updated": "2017-05-19T13:29:54.000+0000" }, { "id": "420147", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Please test this on device. Let us know the version you are testing.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-05-22T19:40:27.000+0000", "updated": "2017-05-22T19:40:27.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }