codelex-io / react-native-prep

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Native Prep

Mac is required to build for iOS, but Android development can be done on Mac, Windows or Linux.

We are going to develop an app using Android emulator on your computer, if you really want you can:

  • use a real Android device connected to your computer with a cable
  • use iPhone emulator / real device (Mac is required)

Environment Setup

  • We are going to write code using Visual Studio Code
  • Latest stable version of node must be installed, check the version using node -v. Download latest stable version @nodejs.org if needed. If you have conflicting versions on your local machine and you cannot start the app, try using Node Version Manager to switch between versions.

Environment Setup for Android

  • Make sure you have Java 8 (aka Java 1.8) installed by executing java -version. Installation instructions:
  • Check that you have JAVA_HOME environment variable set to Java 8 location
  • Android Studio, make sure that you download Android Virtual Device
  • You will need to accept all the licences, SDK is probably somewhere in your home folder and there will be instructions on the first launch

Environment Setup for iOS

Please refer to the official documentation @facebook.github.io or tutorial @egghead.io.

Running an Application

npm run start in you project root directory, this command starts a JS server:

NB! DO NOT close this terminal session

npm run start

npx react-native run-android or npx react-native run-ios, in your project root directory, this command starts the app on your phone / emulator

run-android

Running an Application on Android

NB! We are NOT using Expo!

Go through the offical documentation @facebook.github.io.

Open Android Studio and launch AVD manager from the top-right corner:

AVD Manager

Select the device and launch it:

NB! When an emulator opens, you can close Android Studio to save resources on you computer.

Launch Emulator

If everything went well you should see a working application:

Success

That is it for now, it is recommended to follow the instructions on the screen and get familiar with the mentioned resources.

Troubleshooting

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file...

Create a file called local.properties in the android/app directory.

Find Android Sdk location, on Linux it should be in your home folder.

Add single line in the file:

sdk.dir=/home/{your-user-name}/Android/Sdk

About


Languages

Language:Objective-C 29.4%Language:TypeScript 22.4%Language:Ruby 19.7%Language:Java 18.5%Language:JavaScript 5.8%Language:Python 4.2%