2

I have seen bellow report from my .apk using android build->analysis apk. enter image description here

I have used progrud bellow like

  buildTypes {
    release {
        shrinkResources true
        minifyEnabled true
        zipAlignEnabled true
        //Other parameters
        debuggable false
        jniDebuggable false
        renderscriptDebuggable false

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

}

But My debug apk size is 26.9 MB. When I want to build for release apk then its size become 23.5 MB. It is big in size. Please help me for reduce my apk or reduce at least 60%. Thanks Enamul

Enamul Haque
  • 823
  • 1
  • 14
  • 24

3 Answers3

5

Splitting apk is a good solution. But here is once more trick.

If you just include armeabi-v7a in your apk, that will be fine unless you support < 4.4 android versions.

ARMv6 is no longer supported by Android since android 4.4 (Oct 13)

See this Unity Statics, You just need to include ARMv7 & Intelx86 to make support your app 100% devices.

Now what you have to do is just include ARMv7 & x86 in your app. See abiFilter.

  • Add this to your app level build.gradle

    buildTypes { release { ndk { abiFilters "x86", "armeabi-v7a" } }

  • Press Sync

  • Build and check size

image

Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
0

The only way it is to build apk for each abi

Here is short example:

android {
    splits {
        abi {
            enable true
            reset()
            include "mips", "x86", "x86_64", "armeabi-v7a", "armeabi-v7a", "arm64-v8a"
        }
    }
}

You will get apk's for different architectures with single JNI lib in it.

But you also need to implement special versioning process for it, so there will be no problem to upload apk in Google Play.

Like this:

android {
    def abiCodes = ['mips':1, 'x86':2, 'x86_64':3, 'armeabi':4, 'armeabi-v7a':5, 'arm64-v8a':6]
    android.applicationVariants.all { variant ->
        variant.outputs.each {
            output ->
                def abiName = output.getFilter(OutputFile.ABI)
                output.versionCodeOverride = abiCodes.get(abiName, 0) * 100000 + variant.versionCode
        }
    }
}
Anton A.
  • 1,718
  • 15
  • 37
-1

Use lint and remove unwanted resources from your code. This is link Remove all unused resources from an android project

It may help you.

Learning Always
  • 1,563
  • 4
  • 29
  • 49