How to reduce the size of an expo/react-native app on Android

后端 未结 9 1073
渐次进展
渐次进展 2020-11-30 20:12

I am developing a small dictionary app by using react native with expo.

As I am compiling to Apk file. The size goes up to 30mb and after having installed on a devi

9条回答
  •  眼角桃花
    2020-11-30 21:04

    Make following changes in build.gradle file located at:

    ./android/app/build.gradle
    

    Remove x86 from abi filters.

    splits {
            abi {
                reset()
                enable true
                universalApk false
                include "armeabi-v7a", "x86"
            }
        }
    

    Generate different APK's for different architecture

    def enableSeparateBuildPerCPUArchitecture = true
    

    Enable ProGuard :

    def enableProguardInReleaseBuilds = true
    

    Also set minifyEnabled true and shrinkResources true

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

    Also, you can have different build types for development and release builds(depends on your user base)

    buildTypes {
            debug {
                ndk {
                    abiFilters "armeabi-v7a", "x86"
                }
                ....
            }
    
            release {
                ndk {
                    abiFilters "armeabi-v7a", "arm64-v8a"
                }
                ....
            }
    

    Also don't forget to remove the unused FONT Files

提交回复
热议问题