Subdirectories on Android

I know this topic has been discussed (that you can’t put images, sounds, etc. in subdirectories if you want to deploy to Android), but all I’ve seen is that it’s a “known bug”.

My question is, is this going to be fixed, or is it something that will always be a problem? It hurts my eyes every time I look at a root directory with tons of files in it, so I’m wondering if I need to get used to it or hold out hope that the issue will get fixed. [import]uid: 52127 topic_id: 9139 reply_id: 309139[/import]

fixed

images can be on subdirectories ! — scan the forums ! fixed as of many revisions ago on daily builds and release.

the only things that need to be in root for android are sound and movies…

lua files has to be on root but that is a corona must have.

c. [import]uid: 24 topic_id: 9139 reply_id: 33320[/import]

I’m using build 484. Testing on a Droid running 2.2 - I get a blank screen if I use an image subdirectory. [import]uid: 52127 topic_id: 9139 reply_id: 33430[/import]

did you do the typical checklist
image has to be rgb color 8 bit
image cannot have icc embedded profile
image cannot have reserved java names
image cannot have _ # or weird characters
if two or more files have the same name but different extensions that wont work
correct uppercase/lowercase - devices enforce that casing musth match

c. [import]uid: 24 topic_id: 9139 reply_id: 33434[/import]

Confirmed with another test project that this doesn’t work.

–in main.lua:

–this works

bg = display.newImage( "test.png", true )

–rebuild with this instead, and move the image to /images folder:

bg = display.newImage( "images/test.png", true )

–get a black screen on the device (works in simulator)

The image is a simple RGB 8-bit from photoshop. [import]uid: 52127 topic_id: 9139 reply_id: 33500[/import]

what bulid of corona are you using?

we fix this in the release.

c [import]uid: 24 topic_id: 9139 reply_id: 33505[/import]

I’m using build 484.

I also tried the following, but still get a blank screen:

bg = display.newImageRect("images/grid.png", 570, 380 );

are you on irc? am there right now…

is the actual file name lowercase? all lowercase? remember android and iphone the upper/lowecase has to match.

c [import]uid: 24 topic_id: 9139 reply_id: 33510[/import]

send me source or apk [import]uid: 24 topic_id: 9139 reply_id: 33511[/import]

I just tested the following code using build 484 on a Nexus One and it works fine.

img1 = display.newImage("images/gnc.png", 0, 0 );  
img1.x = display.contentCenterX  
img1.y = 50  
  
img2 = display.newImageRect("images/gnc.png", 57, 57 );  
img2.x = display.contentCenterX  
img2.y = 200  

The gnc.png image was in the /images subfolder. [import]uid: 7559 topic_id: 9139 reply_id: 33514[/import]

Then how about spritesheet image? Last time i must drop it in same folder with the lua [import]uid: 41267 topic_id: 9139 reply_id: 33519[/import]

> the only things that need to be in root for android are sound and movies…

@Carlos: Why is this discrimination about sound files?
When will this be fixed?
We really need this, as our game has a LOT of sound files currently placed in subfolders (works fine on iOS) [import]uid: 9058 topic_id: 9139 reply_id: 33540[/import]

There is currently no fix in the works for allowing sound or video files in subfolders.

The problem is how Android treats media files and moves them to an internal RES folder in the APK (which we have no control over). Android doesn’t have a file structure like iOS and everything is packed in to a “zip” type file so it makes it difficult to deal with. [import]uid: 7559 topic_id: 9139 reply_id: 33590[/import]

Verified working. The problem was that my system was firing an old version of the simulator. Thanks. [import]uid: 52127 topic_id: 9139 reply_id: 33614[/import]

@Tom: I see, but what about AssetManager. It has access to folder structure from /assets folder. Placing all audio and video files into asset folder is better that raw file structure.
Please, comment. Thanks! [import]uid: 9058 topic_id: 9139 reply_id: 34244[/import]

Can you use multiple levels of sub directories or just one? Ex: images/levelone/pic.png [import]uid: 31005 topic_id: 9139 reply_id: 34713[/import]

So this only applies to images loaded via display.newImage()?

What about text files, and other file-types? I need to read text files from deeply nested resource subdirectories. [import]uid: 4596 topic_id: 9139 reply_id: 35278[/import]

@singh206 - try it. All file types except for audio/movies should work in subdirectories.

Have you tried a sample on the device? Try it.

C. [import]uid: 24 topic_id: 9139 reply_id: 35297[/import]

@carlos

I’ve been able to load files from subdirectories in the simulator, but on devices I’m getting errors that say the files don’t exist. This is using system.pathForFile, and io.open.


W/System.err(18782): java.io.FileNotFoundException: /data/data/com.test.app/files/coronaResources/test/afile.xml (No such file or directory)
[import]uid: 4596 topic_id: 9139 reply_id: 35308[/import]

The file i/o on Android cannot access subdirectories. The only thing you can use in subdirectories are image files and they can only be accessed with the display.newImage and display.newImageRect APIs.

Here is a list of things that you can and cannot do with files on Android devices. I will add this to our formal documentation.

What you CANNOT do:

  • Use the file system to access files in subdirectories (off the Resource directory)
  • Use the file system to access image or html files in Resource directory
  • Have sound files in subdirectories
  • Have sound files with the same name but different extensions in the Resource directory
  • native.webPopups can’t access local html files in the Documents or Temporary directories (Note: This has been fixed in our daily builds.)

What you CAN do:

  • Display images from the Resource directory
  • Display images from subdirectories (off the Resource directory)
  • Display images from the Documents and Temporary directories
  • Play sound files from Resource, Documents, and Temporary directories (using openAL API)
  • Use the file system to access: txt, xml, sound, ppp and db files in the Resource directory (I don’t have a complete list but for now only image and html files seem restricted)
  • Copy the above files from the Resource directory to the Documents or Temporary directory
  • Copy image and html files from the Resource directory to the Documents or Temporary directory by changing the file extension (e.g., ppp) and renaming it back to the original file name after the copy.

None of the above limitations apply to iOS devices or the Mac and Windows Simulator.
[import]uid: 7559 topic_id: 9139 reply_id: 35313[/import]