Search code examples
javascriptandroidreact-nativeapkmetro-bundler

Does Binaries (native code) and JS bundle actually packed inside an executable file (APK) for targeted platform?


I am just understanding the architecture of react native. It is written that Binary code and JS code is bundled together in one APK. when I generate an APK there is only binary code.

where as I am assuming that APK contains both JS code binary code. How these two code (binaries for native and JS code) bundled together in one APK?


Solution

  • You are correct! In React Native, the binary code and JavaScript code are bundled together into a single APK file when you generate an APK for release. The bundling process is done using a tool called Metro Bundler, which compiles your JavaScript code into a highly optimized format and packages it into the APK along with the binary code.

    To generate an APK file that contains both the binary code and the JavaScript code, you need to run the command to build your app for release. The resulting APK file will be quite large due to the inclusion of both types of code, but you can optimize its size using tools such as ProGuard.

    Long story short, the bundling process in React Native allows your app to be run on any Android device without the need for the device to have a pre-installed JavaScript engine.