Maximum size for android application?

2019-09-03 02:16发布

问题:

I'm having a hard time finding an updated answer for this.

So far I've been aiming to land my resources <16mb. But This is getting harder and harder the further along I get, I mean, a 1000x1000 .Png-file uses around 1mb.

Obviously I'm aiming to keep it as small as possible, but at what size should I start worrying? Planning on releasing for android >2.1

回答1:

You can get the maximum healp size with:

    Log.d(TAG,"Memory Class: " + ((ActivityManager) getSystemService(ACTIVITY_SERVICE)).getMemoryClass());
    Log.d(TAG,"Heap size: " + Runtime.getRuntime().maxMemory());

If you are loading big PNG files, you should look for the best practices on how to handle big images on Android, but have in mind that some of your options for the BitmapFactory have huge impact on how the image is loaded:

-inScaled when set may increase the bitmap memory size by a factor 2 or 3 in new devices with high screen density,

-ARGB type may go from 2 bytes per pixel (RGB_565 and ARGB_4444) to 4 bytes (ARGB_8888), so a factor of 2 again.

good luck.



回答2:

The lowest heap space you will ever get is 16 MB, IIRC. It is possible that you may be given upto 64 MB, or even more, but you should always try and operate under 16 MB. Remember that if you can possibly get more heap space, and you do try and use it up you could end up displacing other apps from the memory, and cause some minor or in some cases major problems to users.

It's not that you can't get more space. The fact is that you should make your app as good an Android citizen as possible, and be as friendly to the device as you can.



标签: android size