fhircore
fhircore copied to clipboard
Release APK Minification and Shrinking
Describe the feature request. OpensSRP 2 release APKs are currently not optimized for size, resulting in larger APKs that may have an effect on app performance. Minification and shrinking can help reduce APK size by removing unused code, resources and libraries. It also helps improve app performance and ensures only necessary components are packaged.
Additional context Benefits from enabling minification and shrinking:
- Reduced APK size
- Improved app performance
- Obfuscation increases app security
- Meet Play Store requirements of 150 MB size limit
Acceptance criteria
- Minification and shrinking are enabled for release builds
- APK size is significantly reduced compared to current non-shrunk builds
- No crashes or unexpected behaviour with the minified APK
- APK functions correctly across multiple devices and Android versions
- Obfuscation does not interfere with the readability or functionality of critical logs for debugging purposes
Implementation plan (For Engineers)
-
Enable Minification and Shrinking
- In build.gradle under buildTypes > release:
getByName("release") { isMinifyEnabled = true isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) ... }
- Configure Sentry
- Add Sentry configs for reporting minified and obfuscated code
- Configure ProGuard/R8
- Update ProGuard rules to prevent important classes and libraries from being stripped or obfuscated
- Ensure logging, exception handing and other external libraries are retained
- Testing
- Build and test on different devices with different Android versions to confirm that there are no crashes, missing resources and performance degradation
- Confirm reduction of the APK size with shrinking and minification enabled
- Test UI and other functions to ensure alal features work correctly
- Logging & Debugging
- Ensure that mapping files are generated and saved during the build process for debugging when obfuscation enabled
- Verify that important log entries are still readable and useful for debugging
- Documentation
- Document known issues, workarounds related to ProGuard rules added
References