size of the apk file increased when compared to first app uses more screens but less MB (69MB)but second less screens More apk file size (151MB)
reasons why the apk file size is increased and how to reduce the apk file size
Rayabarapu Likhitha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3
APK size is not dependent on the number of screens.
there are some reasons for this:
-
High-resolution images, videos, and audio files in your asset folder can increase the APK size. (Including multiple versions of images for different screen densities).
-
Large libraries or unused dependencies can bloat the APK. (If you’re using native libraries (NDK), they can add to the size). You can also check your library cost from cost-of-modules
-
Unused resources and assets that are not removed.
However, you can reduce your APK Size from the below steps:
- Enable ProGuard or R8 to minify and optimize your code. This can be done by setting minifyEnabled true in your build.gradle file:
android/app/build.gradle
android {
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
-
Ensure the size of the installed react-native libraries from npm as well as native libraries.
-
Additionally you can do:
-
Open up android/app/build.gradle
-
Set
def enableProguardInReleaseBuilds = true
this would enable Progaurd to compress the Java Bytecode. This reduces the app size by a tad bit. -
Set
def enableSeparateBuildPerCPUArchitecture = true
. Android devices support two major device architectures armebi and x86. By default, RN builds the native libraries for both these architectures into the same apk.