1

I am working on demo project of Floating action button. In build.grade , I am having :

compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'

Size of src folder is : 168 KB Size of build folder is: 18.1 MB Size of apk is 1.5 MB

When i install demo on device , size is 13.91 MB.

In build.grade I have enabled pro guard, done shrink resources But still getting max size. Can any one suggest how to reduce size of apk?

And track whiz resources is consuming more memory? Or its support libraries who are culprit.

Please suggest.

Harneet Kaur
  • 4,487
  • 1
  • 16
  • 16
  • Is this debug build or release? A week or two ago similar question was asked by a user (where his APK size was different than that of his friend's, while the code was the same). It might be related to that. – Sufian Aug 05 '16 at 14:04

2 Answers2

0

The size of APK does not reflect the size of the app when you install it on your device. You should not expect or try to make them to be same.

However, if you want tips about reducing APK size, see this post: https://stackoverflow.com/a/22269935/5250273

Community
  • 1
  • 1
Ugurcan Yildirim
  • 5,973
  • 3
  • 42
  • 73
  • cannot perform these operations, because there is no resource file in mu code. there is no image, no extra xml nothing. – Harneet Kaur Aug 05 '16 at 13:40
  • My concern is what is causing this issue, why apk size is increasing? – Harneet Kaur Aug 05 '16 at 13:41
  • Why do you have such concerns? – Ugurcan Yildirim Aug 05 '16 at 13:45
  • Reason, This is just demo, but in my actual application, its apk size is 20MB, but when i am installing it on device it is showing 85 MB. Which is very high. So i want to know the reason and want to reduce its size . Because no user want heavy app – Harneet Kaur Aug 05 '16 at 13:47
  • I already shared the tips on how to reduce APK size. The opposites of those tips are the reasons, obviously. I don't think there is much thing to do other than those listed. – Ugurcan Yildirim Aug 05 '16 at 13:53
0

If you're running Lollipop or Marshmallow, the VM will be Art. This means there will be Ahead-Of-Time compilation when you install the app, generating native code on top of the classes.dex inside your APK.

This is what takes up space.

geecko
  • 660
  • 1
  • 9
  • 22
  • how to fix this? Is com.android.support this the culprit? – Harneet Kaur Aug 05 '16 at 13:41
  • Root your device and check the size of the apk and the compiled files via ADB. You'll see that the compiled files are your problem. There are tons of instructions everywhere to reduce the size of your APK. Proguard comes to mind. You can't "fix" the fact that your apk gets compiled on your device, that's how it's supposed to work and that's what's taking up space. This is normal. :) – geecko Aug 05 '16 at 18:24