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:

Do 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: 15
Total Views: 598 ,

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome content in your inbox.

We don’t spam! Read our privacy policy for more info.

Oh hi there 👋 It’s nice to meet you.

Sign up to receive awesome content in your inbox.

We don’t spam! Read our privacy policy for more info.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Thank you so much!