Finding files in the Expansion File

Help! I am adapting my iOS app to work on Android, and discovering it is a nightmare. We have big files, video and images, more than 100MB. So, I have to use an expansion file.

However, while Corona kindly creates expansion files for the app, it appears that system.pathForFile() does not adapt.

I cannot “find” files that are (or used to be) in the system.ResourceDirectory. That means my “settings.xml” just disappeared, and clearly, all my other config files will be gone, too. And, the sub-levels, so to speak, will be invisible, so I can’t load those, either.

Moreover, I’m not an Android expert, and I cannot figure out where these files have gone. So, after 40 hours of work, I am at a loss as to how to make this app work…the problem appeared when I turned on the expansion file setting in the build.settings…at the end of the project. No indication there would be trouble until I did that.

Possible fixes:

  1. Please, don’t move anything but media files to the expansion! There’s no need — the chance of anyone creating xml/json/txt files that bump the app over 100MB is about zero.

  2. Adapt the system.pathForFile so it tells us where the media files are, if there are in the expansion. I mean, basically, just adapt it so that if you’re looking a moved media file, it will tell us where it is. 

UPDATES:

  • As I continue to work on this, I’ve discovered a plugin that might help.

  • Also, suggestions to look inside /sdcard/ for my files.

I really have never used expansion files, but reading this blog post:

https://coronalabs.com/blog/2013/04/17/expansion-file-support-for-android/

It seems that all your files should be accessed just as they would if they were in the .APK directly. That is your non-Lua files will be at system.ResourcesDirectory and our API’s will automatically load images, sounds, etc. as if they were in the APK.

Of course this is the point of your frustration. Android APK’s are .zip files that Android does NOT unzip for you. Our API’s extract the files our API’s need. This doesn’t help you with various text files that have other information that you may want access too.

I offer these bits of advice if you’ve not seen them yet:

https://docs.coronalabs.com/guide/data/readWriteFiles/index.html#android-file-restrictions

Rob

So, after a good eight hours straight, setting up in the Google Play store, etc., etc., I managed to upload the APK and the expansion file, then create an alpha version, then download it.

And it works. So, what wasn’t working on simulator is now working. This is documented in various places, that in order to test an expansion file, you have to go through the Google Play store, but it was hard to find that information. 

Conclusions:

  • Corona SDK is still freaking amazing
  • The problems are usually related to a lack of documentation about debugging, or Android, rather than Corona SDK failures. However, since there is no way to know this, one can spend hours flailing like a duck in lead booties.
  • The documentation could use some updating!
    • Tell us what will happen in certain circumstances, e.g. how to test an app with an extension file.
    • Tell us that when we turn on the flag for extension files, we cannot test on device locally, as before
    • Other Android weirdness, e.g. system.pathForFile (nil, system.ResourceDirectory) does not work on Android

I really have never used expansion files, but reading this blog post:

https://coronalabs.com/blog/2013/04/17/expansion-file-support-for-android/

It seems that all your files should be accessed just as they would if they were in the .APK directly. That is your non-Lua files will be at system.ResourcesDirectory and our API’s will automatically load images, sounds, etc. as if they were in the APK.

Of course this is the point of your frustration. Android APK’s are .zip files that Android does NOT unzip for you. Our API’s extract the files our API’s need. This doesn’t help you with various text files that have other information that you may want access too.

I offer these bits of advice if you’ve not seen them yet:

https://docs.coronalabs.com/guide/data/readWriteFiles/index.html#android-file-restrictions

Rob

So, after a good eight hours straight, setting up in the Google Play store, etc., etc., I managed to upload the APK and the expansion file, then create an alpha version, then download it.

And it works. So, what wasn’t working on simulator is now working. This is documented in various places, that in order to test an expansion file, you have to go through the Google Play store, but it was hard to find that information. 

Conclusions:

  • Corona SDK is still freaking amazing
  • The problems are usually related to a lack of documentation about debugging, or Android, rather than Corona SDK failures. However, since there is no way to know this, one can spend hours flailing like a duck in lead booties.
  • The documentation could use some updating!
    • Tell us what will happen in certain circumstances, e.g. how to test an app with an extension file.
    • Tell us that when we turn on the flag for extension files, we cannot test on device locally, as before
    • Other Android weirdness, e.g. system.pathForFile (nil, system.ResourceDirectory) does not work on Android