-4

enter image description here

As you can see the res folder is of 2.2 MB only still the APK size is 17 MB. The lib folder is of 11 MB so I think something is wrong with this. Anybody can suggest me what's wrong with this so that my APK size can be reduced.

Krishna Meena
  • 5,693
  • 5
  • 32
  • 44

2 Answers2

2

1st

android {
    // Other settings

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

2nd

  • Reduce Resource Count and Size.

  • Remove Unused Resources.

3rd

Compress the .jpg files as much as possible, You can use TinyPng

Hope this solves your problem

Abdul Kawee
  • 2,687
  • 1
  • 14
  • 26
  • and if you still need more try to use `proguard-android-optimize.txt` https://developer.android.com/studio/build/shrink-code.html – Ralph Bergmann May 08 '17 at 08:27
2

you are using some native code inside your application(your own app code or maybe the libraries), hence the libs folder and the .so(shared object) files are getting generated.you can't escape from this. lol. anyway you can rectify this problem by splitting your apk for different CPU-architectures. open up your app-level build.gradle and paste this code. you'll get different apks for different CPU-architectures.

splits {
    abi {
        enable true // enable ABI split feature to create one APK per ABI
        universalApk true //generate an additional APK that targets all the ABIs
    }
}
// map for the version code
project.ext.versionCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':5, 'mips64':6, 'x86':8, 'x86_64':9]

android.applicationVariants.all { variant ->
    // assign different version code for each output
    variant.outputs.each { output ->
        output.versionCodeOverride =
                project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode
    }
}

later on, you can upload these apks on play store with particular one architecture only. for more information, refer this great blog and this blog

Jay
  • 2,852
  • 1
  • 15
  • 28