{ "id": "153893", "key": "TIMOB-20223", "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": "2018-06-12T21:35:40.000+0000", "created": "2015-12-16T18:05:03.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "filesystem", "lib" ], "versions": [ { "id": "17532", "name": "Release 5.1.1", "archived": false, "released": true, "releaseDate": "2015-11-24" } ], "issuelinks": [ { "id": "50251", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "154208", "key": "AC-562", "fields": { "summary": "Android: cannot list files in a sources directory with Filesystem.getFiles - getDirectoryListing", "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" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "56613", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "169700", "key": "TIMOB-25231", "fields": { "summary": "Android: Ti.Filesystem.resourcesDirectory returns different list on device", "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": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": null, "updated": "2018-06-12T21:35:45.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": "Under lib directory I created a \"repositories\" dir, and under this dir I put some kind of commonjs modules I would like to load dinamically.\r\nOn iOS I do this and it works:\r\n requirePath = \"repositories/\";\r\n repositoriesDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + requirePath);\r\n repositoriesFiles = repositoriesDir.getDirectoryListing();\r\n // requires and other operations with those files\r\n\r\nOn Android apparently I cannot read files contained inside that directory.\r\nI've found one guy with the same problem on your old forum, but now it's closed and there isn't an answer:\r\nhttps://developer.appcelerator.com/question/179048/where-are-my-alloy-lib-files-in-the-filesystem-on-android", "attachment": [], "flagged": false, "summary": "Android: cannot list files on lib directory with Filesystem.getFiles - getDirectoryListing", "creator": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Android 5.0.2\r\nSDK 5.1.1.GA \r\nSamsung Galaxy Tab S2", "closedSprints": [ { "id": 1039, "state": "closed", "name": "2018 Sprint 12 SDK", "startDate": "2018-06-03T15:22:23.401Z", "endDate": "2018-06-17T15:22:00.000Z", "completeDate": "2018-06-18T20:45:36.363Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "373194", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello [~pic], I have trieded a sample code on Android 4.4.2. It's working. I modified your code a bit. Use \"requirePath = \"/repositories/\"\" as like this. \r\n\r\nh5. My Test\r\n\r\n{code}\r\n$.nav.open();\r\nvar requirePath = \"/resmon/11788.png\";\r\nvar repositoriesDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + requirePath);\r\n//repositoriesFiles = repositoriesDir.getDirectoryListing();\r\n$.images.image = repositoriesDir;\r\n{code}\r\n\r\n{code}\r\n\r\n\t\t\r\n\t\t\t\r\n\t\t\r\n\r\n{code}\r\n\r\n[More info|http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem.File-method-getDirectoryListing] on getDirectoryListing(). Hope this helps, Thanks.\r\n\r\n\r\n\r\n\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2015-12-17T09:20:42.000+0000", "updated": "2015-12-17T09:27:55.000+0000" }, { "id": "373206", "author": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thank you for your answer Sharif but you did another thing, that slash doesn't solve my problem. I'm quite sure that getFile is bugged, and that question on Appcelerator's forum is exactly like mine. I was trying to work with conventions for avoiding mistakes and some configurations but apparently it work's only on iOS.\r\nMy code:\r\n requirePath = \"/repositories/\";\r\n repositoriesDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + \"/repositories/\");\r\n Ti.API.info(repositoriesDir.resolve()); // the same with nativePath\r\n repositoriesFiles = repositoriesDir.getDirectoryListing();\r\n Ti.API.info(repositoriesFiles);\r\nWhat it print:\r\n [INFO] : file:///android_asset/Resources//repositories/\r\n [INFO] : ", "updateAuthor": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-12-17T13:52:41.000+0000", "updated": "2015-12-17T13:52:41.000+0000" }, { "id": "373378", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, According to my code I can take a file from \"resmon\" folder through \"getFile\" and use it to another purpose. I tested this with Android 4.4.2. Seeing your code the \r\n\"repositoriesDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + \"/repositories/\");\" \r\nshould be \r\n\"repositoriesDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + requirePath );\".\r\nThanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2015-12-22T08:42:49.000+0000", "updated": "2015-12-22T08:43:43.000+0000" }, { "id": "373405", "author": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm a bit confused because I'm speaking about listing files inside a folder, and not taking a file. It would be great if somebody would answer my question instead of doing other things, I also linked a discussion about one guy with exactly the same problem...\r\nI thank in advance anybody who will show me hot to list files inside \"lib\" directory with Android (in iOS it works). I need it for making a dynamic require of modules and for storing them inside an object literal.", "updateAuthor": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-12-22T14:57:16.000+0000", "updated": "2015-12-22T14:57:16.000+0000" }, { "id": "373815", "author": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I reproduced the bug in a test environment you can download from here:\r\nhttps://github.com/nonno/Ti.TestProject/tree/dynamic-require-bug\r\n(you should click on the label)\r\n\r\nIt works on iOS, it doesn't work on Android 5. I would be happy if you reopen this bug.", "updateAuthor": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-01-05T16:39:13.000+0000", "updated": "2016-01-05T16:44:39.000+0000" }, { "id": "374369", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "With a default alloy project, I ran:-\r\n{code}\r\nfunction doClick(e) {\r\nvar repositoriesDir, repositoriesFiles ;\r\n \r\nTi.API.info(\"Listing repository files\");\r\n \r\n\r\nrepositoriesDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory );\r\nTi.API.info(\"Listing repository files at \"+Ti.Filesystem.resourcesDirectory);\r\nTi.API.info(\"Dir\"+repositoriesDir);\r\nrepositoriesFiles = repositoriesDir.getDirectoryListing();\r\n \r\nTi.API.info(repositoriesFiles);\r\n}\r\n\r\n\r\n$.index.open();\r\n{code}\r\nAnd it works. I get back a list of files, which in this case is just one file `TiAPI : appicon.png`. back. You need to know the correct path the files are in to get them. Or in this case, you need to put the \"repositories/\" folder in `Resources/' folder. I.e. \"Resources/repositories\"\r\n\r\n", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-01-13T02:40:57.000+0000", "updated": "2016-01-13T02:40:57.000+0000" }, { "id": "374370", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Ran on both Alloy and Classic app. No issues.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-01-13T02:41:27.000+0000", "updated": "2016-01-13T02:41:36.000+0000" }, { "id": "377646", "author": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I tested it with the new sdk 5.2.0.GA on a Samsung Galaxy Tab S2 with Android 5.0, it still doesn't work.", "updateAuthor": { "name": "pic", "key": "pic", "displayName": "Mauro Piccotti", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-02-23T16:26:53.000+0000", "updated": "2016-02-23T16:26:53.000+0000" }, { "id": "438371", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Ticket [TIMOB-25231] will resolve this issue.\r\nThis fix is scheduled to be in Titanium 7.3.0.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-12T21:35:09.000+0000", "updated": "2018-06-12T21:35:09.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }