How to reduce Android App size in react-native?
안드로이드 앱 사이즈 줄이기
1. enableSeparateBuildPerCPUArchitecture
- 사용할 경우 특정 ABI(Android Binary Interface)에맞춰 APK 파일을 따로 따로 생성.
- 이 옵션을 사용하지 않으면 다양한 안드로이드 기기의 ABI를 전부 지원할 수 있는 하나의 APK 파일 생성.
- assembleRelease가 아니라 bundleRelease를 사용하여 AAB(Android App Bundle)을 구글스토어에 업로드할 경우, 자동으로 사용자의 기기의 ABI에 적합한 앱으로 다운로드 된다. 구글스토어에 AAB파일을 업로드할 경우 사용할 필요 없음.
2. shrinkResources, minifyEnabled
- 사용하지 않는 리소스 축소와 코드축소 옵션, React Native 프로젝트로 테스트시 5~10MB 축소시키는 것으로 확인.
3. android/app/build.gradle 파일에서 설정
/** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = true /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = true android { buildTypes { release { // Enables code shrinking, obfuscation, and optimization // for only your project's release build type. minifyEnabled true // Enables resource shrinking, which is performed by the Android Gradle plugin. shrinkResources true // Includes the default ProGuard rules files that are packaged with // the Android Gradle plugin. To learn more, go to the section about // R8 configuration files. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } }
'Develop > Android' 카테고리의 다른 글
Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present (0) | 2022.04.09 |
---|---|
[gradle] googlePlayServicesVersion 설정 방법 (0) | 2021.11.27 |
안드로이드 앱 꺼짐 현상 앱크래시😥 (0) | 2021.10.18 |
[android] MediaPlayer?? ExoPlayer?? (0) | 2021.10.05 |
[android] 실행중인 앱을 강제 종료시키고 싶을 때 (0) | 2021.09.29 |
댓글