{ "id": "153968", "key": "TIMOB-20208", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2016-04-21T02:16:47.000+0000", "created": "2015-12-21T17:28:47.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "Android" ], "versions": [], "issuelinks": [ { "id": "50244", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "153624", "key": "TIMOB-20103", "fields": { "summary": "Remote images aren't loading on Android 6 ", "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" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "51456", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "154687", "key": "TIMOB-20320", "fields": { "summary": "Android: Provide generic requestPermission(s) method", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-22T22:24:14.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Steps to reproduce:*\r\n\r\n1. Add the code below to controllers/index.js:\r\n\r\n{code:javascript}\r\nfunction doClick(e) {\r\n var file = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, \"test.txt\");\r\n\tfile.write(\"i love writing to files\");\r\n}\r\n\r\n$.index.open();\r\n{code}\r\n\r\n2. Launch the app.\r\n\r\n3. Click on the \"Hello, World\" text.\r\n\r\n*Results:*\r\n\r\n\r\n{code:java}\r\n12-21 12:15:24.350: E/TiBlob(12960): (KrollRuntimeThread) [19,12681] /storage/emulated/0/com.androidwritefailure/test.txt: open failed: ENOENT (No such file or directory)\r\n12-21 12:15:24.350: E/TiBlob(12960): java.io.FileNotFoundException: /storage/emulated/0/com.androidwritefailure/test.txt: open failed: ENOENT (No such file or directory)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat libcore.io.IoBridge.open(IoBridge.java:452)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat java.io.FileInputStream.(FileInputStream.java:76)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.io.TiFile.getInputStream(TiFile.java:264)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.TiBlob.getInputStream(TiBlob.java:389)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.TiBlob.guessContentTypeFromStream(TiBlob.java:209)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.TiBlob.loadBitmapInfo(TiBlob.java:270)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.TiBlob.blobFromFile(TiBlob.java:140)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.TiBlob.blobFromFile(TiBlob.java:113)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.io.TiFile.read(TiFile.java:351)\r\n12-21 12:15:24.350: E/TiBlob(12960): \tat org.appcelerator.titanium.TiFileProxy.read(TiFileProxy.java:239)\r\n{code}\r\n\r\n\r\n*Notes:*\r\n\r\nThe code is working in Android 5.1 and Android 5.0.", "attachment": [], "flagged": false, "summary": "Android 6.0: Issues with writing to file", "creator": { "name": "jacobkettle", "key": "jacobkettle", "displayName": "Jacob Budin", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "jacobkettle", "key": "jacobkettle", "displayName": "Jacob Budin", "active": true, "timeZone": "America/New_York" }, "environment": "SDK Version 5.1.1.GA\r\nMac Yosemite 10.10.5\r\nNode v0.12.7\r\nNexus 5X - Android 6.0", "comment": { "comments": [ { "id": "374069", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "This has to do with Storage permission required in Android 6.0.\r\nWorkaround for now is to write it this way:-\r\n{code}\r\n if (Ti.Media.hasCameraPermissions()) {\r\n var f = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, \"tests.txt\");\r\n f.write('writing to the file would be enough to create it');\r\n } else { \r\n Ti.Media.requestCameraPermissions(function(e) {\r\n if (e.success === true) {\r\n var f = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, \"tests.txt\");\r\n f.write('writing to the file would be enough to create it');\r\n } else {\r\n alert(\"Access denied, error: \" + e.error);\r\n }\r\n });\r\n }\r\n{code}\r\n\r\nThis will provide the storage permission needed.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-01-08T08:33:00.000+0000", "updated": "2016-01-08T08:33:00.000+0000" }, { "id": "374073", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "https://github.com/gimdongwoo/Ti-Android-RequestStoragePermission\r\nthis plugin should request only the storage permission without the camera permission.", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-01-08T09:27:01.000+0000", "updated": "2016-01-08T09:27:01.000+0000" }, { "id": "375294", "author": { "name": "c3k", "key": "c3k", "displayName": "carlo", "active": true, "timeZone": "Europe/Berlin" }, "updateAuthor": { "name": "c3k", "key": "c3k", "displayName": "carlo", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-01-26T15:06:41.000+0000", "updated": "2016-01-26T15:06:41.000+0000" }, { "id": "383403", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "Should be fixed by this PR: https://github.com/appcelerator/titanium_mobile/pull/7948\r\nYou can use:\r\n\r\n{code}\r\nvar storagePermission = \"android.permission.READ_EXTERNAL_STORAGE\";\r\nvar hasStoragePerm = Ti.Android.hasPermission(storagePermission);\r\nvar permissionsToRequest = [];\r\nif (!hasStoragePerm) {\r\n permissionsToRequest.push(storagePermission);\r\n}\r\nif (permissionsToRequest.length > 0) {\r\n Ti.Android.requestPermissions(permissionsToRequest, function(e) {\r\n if (e.success) {\r\n Ti.API.info(\"SUCCESS\");\r\n } else {\r\n Ti.API.info(\"ERROR: \" + e.error);\r\n }\r\n });\r\n}\r\n{code}", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-20T19:42:44.000+0000", "updated": "2016-04-20T19:42:44.000+0000" }, { "id": "383456", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Thanks [~michael]\r\n\r\nResolving this ticket as there are tickets that have solved the issue such as TIMOB-20320", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-04-21T02:16:03.000+0000", "updated": "2016-04-21T02:16:03.000+0000" }, { "id": "415122", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as duplicate and links to the related ticket have been provided above.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-22T22:24:14.000+0000", "updated": "2017-03-22T22:24:14.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }