Home > Net >  React Native -PreactNativeArchitectures=x86 always builds all ABIs. How to build only one?
React Native -PreactNativeArchitectures=x86 always builds all ABIs. How to build only one?

Time:10-19

I created a new react-native project with:

npx react-native init foo

Then In foo/android I ran:

 ./gradlew clean bundleRelease -PreactNativeArchitectures=x86

I would expect it to create a .aab file that only contains x86 architecture, but it seems it always has all the architecture ABIs? Looking inside the .aab file it has all the folders:

enter image description here

Also if I run ./gradlew clean bundleRelease

I get the exact same size .aab file with the exact same folder structure, again with all architectures included.

Is -PreactNativeArchitectures bugged or am I using it wrong? How do I only create one architecture for a release bundle and how do I know it's working? Currently -PreactNativeArchitectures seems to be completely ignored.

CodePudding user response:

Got an answer from Cortinico in Github: https://github.com/facebook/react-native/issues/34902

Turns out ABI split are not supported by .aab files. One should build .apk file instead with:

./gradlew clean assembleRelease -PreactNativeArchitectures=x86

Also need to set the following to true in android/app/build.gradle

 def enableSeparateBuildPerCPUArchitecture = true
  • Related