How come .apk is twice the size of .ipa?

If apk file is just a zip file then how come the ipa I produced (which is just a zip file for the whole app) has half the size of the apk I build?

My game requires tons of text files, which if properly zipped will go from 30MB to 1.9MB and that’s what I get when I make my iOS build. But when I got my apk file from the build process nothing seems to be compressed.

Is there a way to reduce my apk size by compressing my text files (xmls mostly)

thnaks

actually, i just used apktool to decompile and recompile my apk and BOOM… apk size reduced from 70MB to 36MB.

Is the build process from corona doesn’t compress anything in the resource directory?

Correct.  Corona does not compress the resource files within the APK.  We do this on purpose.  The reason is because loading compressed resources can take about 4x longer to load than uncompressed resources… which makes sense because the resource files would have to be decompressed first before actually loading them.  Fast app load times, especially when resuming after a suspend, is considered more important.

I can think of two work-arounds for you:

  1. Pre-compress your large text files in your project and have them decompressed to the temporary directory at runtime.

  2. If you plan on adding more large files in the future, then use an expansion file.  But this is not really worth it if your app is only 70 MB.

Exactly, 70MB is too close to 50MB and  I know I can make it below 50MB if some text files are compressed.  Anyway I’ve done the test with the compressed apk and the load time isn’t that bad and no longer than some of the games out there.

The only problem is, now the app doesn’t work on some part and I was wondering if it’s because of the compressed files.

Sorry if this isn’t Corona related but if I compress my apk can io functions work properly?

Is there anything that I need to change/do to make it work?

Features that involve passing a file reference to other apps or activity windows typically won’t work with compressed files within an APK.  Features such as media.playVideo and mail attachments via native.showPopup().  The reason is because they don’t have direct access to your APK’s files and must be given what Android calls an AssetFileDescriptor, which is really just a byte offset and byte count of your resource file within your APK.  The trouble is that these external apps and activity windows don’t expect these assets to be compressed and read in those bytes as-is.

We do have a zip plugin that you can use.  I’m thinking that you could compress your large text files in your project and then have your app decompress them at runtime to the caches or temporary directory.  This might be the simplest solution.

   http://docs.coronalabs.com/daily/plugin/zip/index.html

Alternatively, when you re-zip your APK, you should have some command line options to tell the zip utility which files or file extensions you want to compress.  I don’t know the command line options off hand, so you’re on your own on how to do that.

Anyways, I hope this helps.

actually, i just used apktool to decompile and recompile my apk and BOOM… apk size reduced from 70MB to 36MB.

Is the build process from corona doesn’t compress anything in the resource directory?

Correct.  Corona does not compress the resource files within the APK.  We do this on purpose.  The reason is because loading compressed resources can take about 4x longer to load than uncompressed resources… which makes sense because the resource files would have to be decompressed first before actually loading them.  Fast app load times, especially when resuming after a suspend, is considered more important.

I can think of two work-arounds for you:

  1. Pre-compress your large text files in your project and have them decompressed to the temporary directory at runtime.

  2. If you plan on adding more large files in the future, then use an expansion file.  But this is not really worth it if your app is only 70 MB.

Exactly, 70MB is too close to 50MB and  I know I can make it below 50MB if some text files are compressed.  Anyway I’ve done the test with the compressed apk and the load time isn’t that bad and no longer than some of the games out there.

The only problem is, now the app doesn’t work on some part and I was wondering if it’s because of the compressed files.

Sorry if this isn’t Corona related but if I compress my apk can io functions work properly?

Is there anything that I need to change/do to make it work?

Features that involve passing a file reference to other apps or activity windows typically won’t work with compressed files within an APK.  Features such as media.playVideo and mail attachments via native.showPopup().  The reason is because they don’t have direct access to your APK’s files and must be given what Android calls an AssetFileDescriptor, which is really just a byte offset and byte count of your resource file within your APK.  The trouble is that these external apps and activity windows don’t expect these assets to be compressed and read in those bytes as-is.

We do have a zip plugin that you can use.  I’m thinking that you could compress your large text files in your project and then have your app decompress them at runtime to the caches or temporary directory.  This might be the simplest solution.

   http://docs.coronalabs.com/daily/plugin/zip/index.html

Alternatively, when you re-zip your APK, you should have some command line options to tell the zip utility which files or file extensions you want to compress.  I don’t know the command line options off hand, so you’re on your own on how to do that.

Anyways, I hope this helps.