Comments (14)
I did some tests with the universal APK (containing all architectures) and splitting the APKs by architecture. The APK generated by
gradlew assembleRelease
does indeed shows an increase in size between the two React Native versions:
- (Universal) RN 0.72.5: 20.6 MB
- (Universal) RN 0.74.0: 50.6 MB
- (x86_64 only) RN 0.72.5: 8.2 MB
- (x86_64 only) RN 0.74.0: 16.9 MB
However, once the app is installed on the device, the single-architecture APK exhibits a reduction in app size:
- (Universal) RN 0.72.5: 43.8 MB
- (Universal) RN 0.74.0: 62.4 MB
- (x86_64 only) RN 0.72.5: 30.8 MB
- (x86_64 only) RN 0.74.0: 27.1 MB
If the app is distributed through an app store like Google Play, the store may generate an "optimized APK" for the users. Using the App Analyzer tool bundled with Android Studio, the estimated "Download Size" of the APKs is basically the same:
- (Universal) RN 0.72.5: 20.3 MB
- (Universal) RN 0.74.0: 19.6 MB
- (x86_64 only) RN 0.72.5: 7.9 MB
- (x86_64 only) RN 0.74.0: 8.1 MB
So users from an app store may not notice changes in the download or installed size of the app. But the increase in the size of the APK could be noticeable for some developers and users who download the APKs directly.
Hey all,
Nicola here from the React Native team.
@jonasbantunes shared the correct answer here.
A couple of points for folks in this discussion:
-
Comparing the APK size on disk is not a good indicator of App size. That's especially true if you use App Bundles to distribute your app via the Play Store (as APKs will be produced from the App Bundle based on the device architecture).
-
You should compare either the compressed APK size (shown by Android Studio if you open the APK inside Android Studio) or the app size on device (via the App Info screen).
Specifically in 0.74, we reduced the App size on device by ~13% due to minSDK bump and removal of several unnecessary dynamic libraries (see https://reactnative.dev/blog/2024/04/22/release-0.74#bonus-android-app-size-reduction).
That's the metric that @jonasbantunes mentioned here:
- (x86_64 only) RN 0.72.5: 30.8 MB
- (x86_64 only) RN 0.74.0: 27.1 MB
Also
So users from an app store may not notice changes in the download or installed size of the app. But the increase in the size of the APK could be noticeable for some developers and users who download the APKs directly.
Users from App Stores will benefit from a reduction on App size on device.
The increase in APK size could be noticeable if you download the APK manually and distribute it to your users/developers that way (i.e. for test users or so).
The reason why you're seeing an APK size increase on disk, it's because the dex files are uncompressed starting from AGP 8.2 + with the minSdk bump to 23, the native libs are also shipped uncompressed on the APK. Regardless of compression inside the APK, when the APK is distributed through the wire it's compressed all together (so the 30Mb you see on disk are irrelevant for the users).
<application ... android:extractNativeLibs="true">
This is also not recommended as it will make your app slower.
from react-native.
21 to 23 causes this https://stackoverflow.com/questions/66511524/react-native-changing-minsdkversion-from-21-to-23-doubled-the-app-apk-size
from react-native.
I did some tests with the universal APK (containing all architectures) and splitting the APKs by architecture. The APK generated by gradlew assembleRelease
does indeed shows an increase in size between the two React Native versions:
- (Universal) RN 0.72.5: 20.6 MB
- (Universal) RN 0.74.0: 50.6 MB
- (x86_64 only) RN 0.72.5: 8.2 MB
- (x86_64 only) RN 0.74.0: 16.9 MB
However, once the app is installed on the device, the single-architecture APK exhibits a reduction in app size:
- (Universal) RN 0.72.5: 43.8 MB
- (Universal) RN 0.74.0: 62.4 MB
- (x86_64 only) RN 0.72.5: 30.8 MB
- (x86_64 only) RN 0.74.0: 27.1 MB
If the app is distributed through an app store like Google Play, the store may generate an "optimized APK" for the users. Using the App Analyzer tool bundled with Android Studio, the estimated "Download Size" of the APKs is basically the same:
- (Universal) RN 0.72.5: 20.3 MB
- (Universal) RN 0.74.0: 19.6 MB
- (x86_64 only) RN 0.72.5: 7.9 MB
- (x86_64 only) RN 0.74.0: 8.1 MB
So users from an app store may not notice changes in the download or installed size of the app. But the increase in the size of the APK could be noticeable for some developers and users who download the APKs directly.
from react-native.
AndroidManifest.xml
<application
...
android:extractNativeLibs="true">
from react-native.
any solution.
APK generated in RN : 0.73.6 : 27 MB
AFTER UPGRADE
APK generated in RN : 0.74.0 : 60 MB
from react-native.
Missing Reproducible Example | |
---|---|
ℹ️ | We could not detect a reproducible example in your issue report. Please provide either:
|
from react-native.
I found this really is a amazing thing, so Why lead to this question.
from react-native.
@Hao-yiwen What was the reason why other had significant difference?
from react-native.
@Hao-yiwen did you figure it out? really interested in this one. Maybe it has something to do with ProGuard config?
from react-native.
Same problem, apk size changed from 53.6M to 114.7M.
from react-native.
Same here. After upgrading to 0.74, the apk size has approximately doubled.
from react-native.
@Abhisflyingsoon Demo is pure reactNative project,don't do other thing.
from react-native.
Same here. After upgrading to 0.74, the apk size has approximately doubled.
android {
//...
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
}
Work for me.
from react-native.
AndroidManifest.xml
<application ... android:extractNativeLibs="true">
that's worked
from react-native.
Related Issues (20)
- After installing react-native-screens ios build not working - Error: info Run CLI with --verbose flag for more details. HOT 2
- 'React/RCTBridgeDelegate.h' file not found HOT 4
- > Task :packages:react-native:ReactAndroid:buildCMakeDebug[arm64-v8a][bridgeless,fabricjni,etc] FAILED FAILURE: Build failed with an exception. HOT 4
- DevSupport classes included in release apks (~40KB size impact) due to DevLoadingModule HOT 2
- FlatList Clipping Issue on iOS with New Architecture Enabled HOT 2
- [iOS] Data race when accessing RCTNetworkTask.status
- AppState is not changes when go to apps switcher (in Android Pixel device) HOT 2
- can't running app :ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed. HOT 4
- Parent border is drawn over the child content HOT 3
- [ios only] No bundle URL error when npx react-native init ProjectName HOT 4
- Metro is not starting on custom port HOT 2
- [0.74.1] Npm install WARN HOT 2
- [codegen]: TypeError: glob.sync is not a function HOT 1
- cocoapods: undefined method `end_with?' for nil:NilClass HOT 1
- [iOS] Static counters lead to data races
- [Bridgeless] Multiple bundles loaded on android when locale changed natively HOT 1
- FBReactNativeSpec/FBReactNativeSpec.h: No such file or directory (in target 'React-Codegen' from project 'Pods') HOT 6
- Unable to run the app on Android 14. HOT 7
- Cannot Make API call to http endpoint when using formData[Tried with both fetch and axios] HOT 3
- 'If-None-Match' and 'If-Modified-Since' Headers being Appended to Outgoing Network DELETE Requests Resulting in Server 501 Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native.