- Following the below steps will help you to reduce the app size by over 60%.
- First compress your asset files (png, jpg, gif), use any online free image compressor website to compress it.
- Enable hermes engine
- Update you proguard rules ->
android/app/proguard-rules.pro
:
- Apply react-native: https://github.com/facebook/react-native/blob/main/ReactAndroid/proguard-rules.pro
- Apply hermes: https://reactnative.dev/docs/hermes
- Apply Zoom SDK:
-keep class us.zoom.**{*;}
-keep class com.zipow.**{*;}
-keep class us.zipow.**{*;}
-keep class org.webrtc.**{*;}
-keep class us.google.protobuf.**{*;}
-keep class com.google.crypto.tink.**{*;}
-keep class androidx.security.crypto.**{*;}
- Make sure to also apply proguard rules for
react-native-*
libs that you use, e.g. forreact-native-svg
->-keep public class com.horcrux.svg.** {*;}
- Open
AndroidManifest.xml
and add insideapplication
tag the following:
<application
...
android:extractNativeLibs="true"
...
>
...
</application>
- Go to
android/app/build.gradle
and enable:
def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = true
Proguard shrinks, optimizes and obfuscates Java code. It is able to optimize bytecode as well as detect and remove unused instructions.
Now add the lines wherever I've mentioned //ADD THIS LINE
:
android {
...
defaultConfig {
applicationId "com.zoom"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 18
resConfigs "en" //ADD THIS LINE
versionName "1.1.7"
multiDexEnabled true
}
...
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
shrinkResources true //ADD THIS LINE
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
...
}
If you're running /gradlew bundleRelease
to release your app on Playstore then you need to disable progaurd
def enableProguardInReleaseBuilds = false
& rest of the above settings will remain the same & once progaurd is disabled then rebuild the app and upload the bundle file to playstore again which will fix the crash.
Google Play uses your app bundle to generate and serve optimized APKs for each device configuration, so only the code and resources that are needed for a specific device are downloaded to run your app. You no longer have to build, sign, and manage multiple APKs to optimize support for different devices, and users get smaller, more-optimized downloads.
See diff for the example app: mieszko4/react-native-zoom-us-test#33
For iOS follow this: ios-reduce-your-app-size-with-app-thinning
Make sure to set
ENABLE_BITCODE = NO;
for both Debug and Release because bitcode is not supported by Zoom iOS SDK