This will take 1 hour or longer depending on Internet and your laptop speed.
In a nutshell, these are the steps:
- Install react native pre-requisites for Windows
- Run HelloWorld React Native app on an Android device
- Run Code & Robots app on an Android device
There are quite a few gotchas when setting up right now. We're working towards a better experience to get started but it's best if you visit the Troubleshooting guide before starting and refer to it if you run into problems. For further support, send an email to [email protected].
I would recommend you follow the steps below. Alternatively you can follow the React Native getting started docs instead.
So grab a coffee ☕ and let's get started.
When running the below steps in a command prompt, it's best to do it as an Administrator.
- To open an Administrator Command Prompt
- Search "Command Prompt", right click "Command Prompt" and select "Run as Administrator"
- Having trouble? See Option 2 in https://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1
-
Open an Administrator Command Prompt
-
Install chocolatey (popular package manager for Windows - see https://chocolatey.org/install)
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
This will take up to 5 mins or longer to complete.
-
Open an Administrator Command Prompt
-
Install Node, Python2, JDK8, Yarn and Git
choco install -y nodejs.install python2 jdk8 yarn git
-
Refresh env in your command prompt (important!)
refreshenv
-
Open an Administrator Command Prompt
-
Install the React Native CLI
npm install -g react-native-cli
This will take up to 20 mins or longer to complete.
-
Download and install Android Studio (1gb download)
- Go to https://developer.android.com/studio/index.html, download and install it
-
Install Android Studio (it will use 3gb of space)
-
Click Finish, then start and setup Android Studio (it will use 1gb of space)
- Choose 'Do not import settings' if you don't have an Android Studio config that you can copy from another laptop
- Choose 'Standard' setup
-
Open a Administrator Command Prompt and get your username
echo %username%
-
Get the path to the Android SDK
- Copy
C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk
and replace YOUR_USERNAME with your username from Step 1
- Copy
-
Add ANDROID_HOME system environment variable
- Search "Edit system", click "Edit the system environment variables", click on "Environment Variables"
- Click New under the System variables section (NOT the User variables section)
- Set ANDROID_HOME as the Variable name
- Paste the path to the Android SDK from Step 2 as the Variable value
- Click OK
-
Refresh env in your command prompt (important!)
refreshenv
-
Check that ANDROID_HOME is set correctly
echo %ANDROID_HOME%
-
Open a Administrator Command Prompt and get your username
echo %username%
-
Get the path to the Android SDK platform tools
- Copy
C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools
and replace YOUR_USERNAME with your username from Step 1
- Copy
-
Edit Path user environment variable and add the Android SDK platform tools path
- Search "Edit system", click "Edit the system environment variables", click on "Environment Variables"
- Select "Path" under the User variables section (NOT the System variables section) and click on Edit
- Click New
- Paste the path to the Android SDK platform tools from Step 2
- Click OK
-
Refresh env in your command prompt (important!)
refreshenv
-
Check adb (e.g. a useful Android platform tool) is available
adb version
-
Open a Administrator Command Prompt
-
Accept Android SDK licenses
cd "%ANDROID_HOME%"\tools\bin
sdkmanager --licenses
- Accept the licenses
Time to test that React Native works on a real Android device.
Hint: You can also test on a virtual device, see https://developer.android.com/studio/run/managing-avds.html.
-
Open a Administrator Command Prompt
-
Create the HelloWorld project
cd C:\Users\%username%
react-native init HelloWorld
-
Enable developer options on your Android device (See https://developer.android.com/studio/debug/dev-options#enable)
- Open the Settings app on your device
- Select System (Only on Android 8.0 or higher)
- Scroll to the bottom and select About phone
- Scroll to the bottom and tap Build number 7 times
- Return to the previous screen, scroll down and select Developer options
- Scroll down a little and enable USB debugging
-
Connect your Android device via USB to your laptop
The next step will take a few minutes, make sure to click "Allow Access" if asked to by a Firewall popup.
- Install and run the app on your Android device
cd HelloWorld
react-native run-android
If you see the error "Device is UNAUTHORIZED", make sure to click OK when the popup "Allow USB debugging" shows on your device.
To check to see if your device is connected and authorized:
adb devices
Follow the instructions in https://github.com/codeandrobots/codeandrobots-app#arrow_up-how-to-setup, i.e:
cd C:\Users\%username%
git clone https://github.com/codeandrobots/codeandrobots-app.git
yarn install --ignore-engines
copy .env.example .env
react-native run-android --variant=devDebug