Giter Site home page Giter Site logo

I compare 0.72.5 and 0.74.0 react native android app size,0.74.0 is 50MB,And 0.72.5 is 21.7 MB.How to reduce 0.74.0 android app size? about react-native HOT 14 CLOSED

Hao-yiwen avatar Hao-yiwen commented on June 14, 2024
I compare 0.72.5 and 0.74.0 react native android app size,0.74.0 is 50MB,And 0.72.5 is 21.7 MB.How to reduce 0.74.0 android app size?

from react-native.

Comments (14)

cortinico avatar cortinico commented on June 14, 2024 9

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:

  1. 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).

  2. 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.

Daniel3711997 avatar Daniel3711997 commented on June 14, 2024 5

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.

jonasbantunes avatar jonasbantunes commented on June 14, 2024 5

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.

baesumin avatar baesumin commented on June 14, 2024 1

AndroidManifest.xml

<application
...
android:extractNativeLibs="true">

from react-native.

danish5454 avatar danish5454 commented on June 14, 2024 1

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.

github-actions avatar github-actions commented on June 14, 2024
⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

from react-native.

Hao-yiwen avatar Hao-yiwen commented on June 14, 2024

I found this really is a amazing thing, so Why lead to this question.

from react-native.

aziyatali avatar aziyatali commented on June 14, 2024

@Hao-yiwen What was the reason why other had significant difference?

from react-native.

Abhisflyingsoon avatar Abhisflyingsoon commented on June 14, 2024

@Hao-yiwen did you figure it out? really interested in this one. Maybe it has something to do with ProGuard config?

from react-native.

b1ngx avatar b1ngx commented on June 14, 2024

Same problem, apk size changed from 53.6M to 114.7M.

from react-native.

1280103995 avatar 1280103995 commented on June 14, 2024

Same here. After upgrading to 0.74, the apk size has approximately doubled.

from react-native.

Hao-yiwen avatar Hao-yiwen commented on June 14, 2024

@Abhisflyingsoon Demo is pure reactNative project,don't do other thing.

from react-native.

1280103995 avatar 1280103995 commented on June 14, 2024

Same here. After upgrading to 0.74, the apk size has approximately doubled.

android {
    //...
    packagingOptions {
        jniLibs {
            useLegacyPackaging true
        }
    }
}

Work for me.

from react-native.

danish5454 avatar danish5454 commented on June 14, 2024

AndroidManifest.xml

<application ... android:extractNativeLibs="true">

that's worked

from react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.