Creating a React-Native Application

Before creating a React Native Application in Windows, i recommend to use Chocolatey. It’s a package manager application, just like yum, apt, dnf, portsnap in Linux and BSD. Install chocolatey as administrator with following CMD command.

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(''))

I recommend to install NodeJS (especially LTS), JDK and Python in case if we need to follow react-native command instead of Expo CLI.

choco install -y nodejs-lts python2 jdk8

Now we are ready to install react-native cli to create our sample project.

npm install -g react-native-cli

Now we need to install Android Studio. Get it from there:

We need to set two environment variable. Go in to Control Panel. Choose System and Security -> Change Settings -> Advanced Tab -> Environment Variables and click New. Set a ANDROID_HOME variable with location C:\Users\<em>YOUR_USERNAME</em>\AppData\Local\Android\Sdk , secondly set a platform-tools variable with path C:\Users\<em>YOUR_USERNAME</em>\AppData\Local\Android\Sdk\platform-tools . Change YOUR_USERNAME with your Windows username.

Now it’s Android Studio part. We need to download couple things and create an emulator device. Open it., yes. Click Configure -> SDK Manager. Check Android 9.0 (Pie), then check Show Package Details and check Google APIs Intel x86 Atom System Image and Android SDK Platform 28 etc.

Now come to the SDK Tools path and download Android SDK Build Tools, version 28.0.3.

Click Apply.

Turn back to Android Studio intro menu.

Click Configure -> AVD Manager -> Create Virtual Device -> ? A device choice of yours i choose Pixel 2 -> Choose Pie as System Image.

If you did all of these things, let’s create our sample project.

react-native init MySampleProject

Come in with cd MySampleProject. Run it in debug mode.

react-native run-android

Probably you get an error while building… Finally, there is a tweak that you need to do in your created MySampleProject folder. Go in to android folder, edit build.gradle file then change to minSdkVersion =  28

Leave a comment

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