react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

❓ Reduce release bundle size

Open PavelRazumov opened this issue 3 years ago • 5 comments

Question

Hi, team.

I use this library only for reading barcodes. My question is is there an opportunity to reduce the size of the bundle of the final release application? As an example for comparison, I created two applications using npx react-native init https://reactnative.dev/docs/environment-setup (version 0.66.0), and for one of them I added the react-native-vision camera library (version 2.13.2) with reanimated (version 2.4.0) and launched the release build with the minifyEnabled true flag

// Empty app

// App with react-native-vision-camera

Is there any solution to optimize the releaser apk build ?

What I tried

  1. Create two empty projects with help npx react-native init
  2. One of them add dependencies react-native-vision-camera, react-native-reanimated and vision-camera-code-scanner
  3. Launching release build for both app with flag minifyEnabled true.
  4. Check apk's result

VisionCamera Version

2.13.2

Additional information

PavelRazumov avatar Aug 22 '22 12:08 PavelRazumov

I try add compile flag like -Os or -O3 (https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options) in build.gradle in react-native-vision-camera, but unfortunately it didn't work

PavelRazumov avatar Aug 22 '22 12:08 PavelRazumov

In my case, i was set minSdkVersion = 23 and apk size is increased. Finally i change it to 21 .

I will back later to share the information source

EDIT:

https://github.com/zoontek/react-native-bootsplash/issues/288#issuecomment-981907888 I got information source from this comment. So my android/build.gradle look like below:

....

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21 // <= set to 21
        compileSdkVersion = 31
        targetSdkVersion = 31
....

I hope it can help you...

babaiyu avatar Sep 06 '22 08:09 babaiyu

@babaiyu, hi,

I don't understand, what do you mean about minSdkVersion and boostsplah? In my question i want to reduce size of react-native-vision-camera only, and my minSdkVersion is 23 it's actual version of Android 6 (out minimal support version)

PavelRazumov avatar Sep 06 '22 09:09 PavelRazumov

@babaiyu, hi,

I don't understand, what do you mean about minSdkVersion and boostsplah? In my question i want to reduce size of react-native-vision-camera only, and my minSdkVersion is 23 it's actual version of Android 6 (out minimal support version)

Nevermind with bootsplash, it just example case to other libraries hehe.

https://stackoverflow.com/a/68219448 I found this question from stackoverflow, please redirect to link above. I hope it can help to.

Sorry before, my bad english.

babaiyu avatar Sep 06 '22 09:09 babaiyu

ok, thank you, i'll check it later and return with result

PavelRazumov avatar Sep 06 '22 10:09 PavelRazumov

Closing as this is a stale issue - this might have been fixed with the full rewrite in VisionCamera V3 (🥳) - if not, please create a new issue.

If your issue has been fixed, consider sponsoring me on GitHub to say thanks 💖

mrousavy avatar Sep 30 '23 09:09 mrousavy