简体   繁体   中英

How to locally install react native app in physical android phone?

I have developed a simple app with just a login and home page (no functionalities yet just pure layout and navigation of screens). And I wanted to install it in my android phone. So far when I searched on stackoverflow, there was a similar question but the answers were not helpful.

I need the app to be installed and to run without the need to be connected to a network. Just like when using android studio, when you run your app it installs the apk in your phone.

You can generate a debug build with all the assets preloaded. That is pretty much you are looking for. This way even if you're app is not connected to metro bundler, it shall work as expected and display all the images etc. Run the following commands from your project root dir :

Copy assets :

react-native bundle --dev true --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

Generate debug build:

cd android && ./gradlew assembleDebug

Look for generated debug build in this folder android/app/build/outputs/apk/debug/

This is well defined in the react-native documentation.

https://facebook.github.io/react-native/docs/getting-started

From here, click on the Build Projects with native code tab, then select your operating system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM