React Native – Run the app in Genymotion Android emulator

I am trying to use React Native these days, it works fine in iOS simulator, but when I try to run the app in android emulator, I encountered some problems!

1.The Java SDK issue.

I have developed the android app with flutter before, so I also have installed the android SDK, and I suppose that will be smooth in RN right now, but when I execute below command to try to run the android:

Are you want to be a good trading in cTrader?   >> TRY IT! <<
react-native run-android

I got the error that missed the Java SDK, and I need to go to Java website for download it.

2.But after installed the Java SDK, I got another error.

It also need to set the [su_label type=”important”]JAVA_HOME[/su_label] and [su_label type=”important”]ANDROID_HOME[/su_label], I use MacOS, so that’s need to set in the [su_label type=”info”]~/.bash_profile[/su_label] file as below:

export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Volumes/SourceCodes/androidSDK/android-sdk-macosx

But the problem still not finish… 😨

3. When everything are ok, I still got below error

This error is very strange, I spend many of times for that, fortunately, I found the solution:

1)Create an [su_label type=”important”]assets[/su_label] folder in below

yourApp_root/anddroid/app/src/main

2)Execute below command

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

after that it will auto generate the [su_label type=”info”]index.android.bundle[/su_label] file in assets folder, and now execute below command for run the android

react-native run-android

The app can be run successfully😁

Loading

Views: 6
Total Views: 83 ,

Leave a Reply

Your email address will not be published. Required fields are marked *