Large .apk file built for "Hello World" app

I am new to Corona and I am a subscriber. I have been watching the tutorial videos and just attempted to build my first Android app (a simple Hello World app) using the latest Corona SDK release (CoronaSDK-2011.591.msi). My code consists of one line that prints a "Hello World!" message to the terminal window. Everything built fine but I am shocked by the resultant APK file size. For my simple app, the APK is 4.181MB!!! This is enormous considering I haven't even written an application yet.

I decompiled the APK file to find out why the app was so large and this is what I discovered:

1) classes.dex --> 1.361MB
2) lib\armeabi-v7a\libcorona.so --> 1.358MB
3) "res" folder --> 423KB

These three files / folders alone cause any app to be at least 3.142MB (without any actual app code). These files make up 75% of the app size. Why are these files so large and why are other libraries / resources included in the APK file if they are not actually used by the app? Is there something I can do to prevent this from occurring? I had expected my app to be less than 100KB (which is only 2% of the actual size). Please help!!!

UPDATE: I also noticed that I have numerous OpenFeint, Papaya and SuperRewards assets and files in my APK file as well. I would definitely not expect these to be included in an app that is not using these services.

that used to be the case with OpenFeint and 8MB of added data, I guess it will take a while then the assests will be on a pure *if used* basis, however I let Ansca reply on that officially.

cheers,

?:)

hmm.-

should be that subscribers don't get any of the libraries you mention if they are *not* in a "require"

hmm.- could it be that you are building on a non-subscriber account?

.c

@Carlos - Thanks for the reply. I am signing in using my subscriber account and I have authorized my PC that I am requesting the build from. Is there some way that I can check whether or not I am building as a subscriber?

Hello everyone,

At the moment, Ansca only has one build template for Android which includes all libraries we support, regardless if your app uses them or not. Our iOS builds are smarter and only include what is "required" by your project. In the future we'd like to change our Android build system to only build-in what is "required" by your project, but at the moment this is how it currently works.

On android market my first game "black box reflections" is 1.2mb

Download apktool, decompile your app, remove any libs you dont need (there are loads spread out over 2 directories, i can go into detail later maybe but i'm on my phone at the moment..)

Can also modify your manifest.xml while youre in there to remove vibrate permissions and change your version codes.

Then i just compress all images, recompile, and use the java signing tool by command line and there you have it, for the sake of literally 1 minute doing this your game goes down in size dramatically

Thanks for the tip on removing the unnecessary libs. Maybe you (or the Corona staff) could put together a short guide on how to do this and share it with the rest of the community. It would be nice to better understand what each of these large files / directories are for so we can better understand how to shrink our android builds. Thanks again!

Yeah it'll be easy enough to put together and i'm sure someone else can refine it. Can throw one over later today after work

Awesome! I am looking forward to it. It would be awesome to be able to create a small script / windows app to help manage this process. Maybe I can throw something together once I see your guide.

ok so i suppose I'll get started with a rough guide (This is all for windows by the way) I'm really only a newbie at corona myself so this isn't definitive, and obviously i'm not responsible if your app causes a human strain of cordyceps and thus the zombie apocalypse:

1-download apktool (it's googleable)

2-build your app with corona

3-take the apk and put it in the "place-apk-here-for-modding" folder of apktool (NOTE your apk filename must not contain spaces or it'll crash the tool, if it does, remove them, you can still put them back later)

4-launch apktool using the "script.bat" file in the apktool folder

5-select options 22, 1 then 9 to decompile your apk. in your apktool root folder, find the "projects" folder, there will be a directory named after your apk

6-see which files you want to delete (for me on xp, going too deep into the "build" folder crashes explorer, so i ignore it). the ones i delete are (note, these may be different for you depending on what you use):

assets->webui
smali->org
smali->com->anything you don't need (I normally delete everything but **my project's dir** and **the ansca dir**, but it depends on what you use. ie if you use facebook stuff don't delete the facebook folder)

7-open the "AndroidManifest.xml" and delete the vibrate permission if you don't use it; then people won't be wondering why they need it/phones that don't support it can still get your app. also delete the internet permissions one if you don't need the internet (some people get suspicious at this, as it is though i use advertising so i've always kept it)

You can also set your version name and version code in here, which i did because whatever version of corona i was using wouldn't let me use decimal points in the version

8-back in apk tool selet 2 to compress your images

9-select 11 to recompile your apk, you can then re-add any spaces and move it back to wherever you want out of the
"place-apk-here-for-modding" folder (it will have an "unsigned" prefix)

10-i dunno if the sign option in apktool is for debugging only, but just in case i then sign my apk again by hand before uploading to market/testing on device:
---

1
2
3
4
5
6
7
8
to create the new keystore if you haven't got one
 
<path to keytool>keytool.exe -genkey -v -keystore <pathtokeystore>yourkeystorename.keystore -alias <atagforyourapp> -keyalg RSA -keysize 2048 -validity 10000
 
then each time you want to sign it run
 
 
<path to jarsigner>jarsigner.exe -verbose -keystore >pathtokeystore>yourkeystorename.keystore <pathtoapk>yourapkname.apk <yourapptagfromabove>

how can we report spammers?

The spam posting has been deleted.

views:2157 update:2011/10/4 8:06:35
corona forums © 2003-2011