Are you looking to build and run Android apps without relying on Android Studio? Look no further! In this article, we'll walk you through the process of installing the Android SDK, a crucial tool for swift app development, and set up your environment for building and running React Native apps.
Step 1: Install Chocolatey
Before we dive into the world of Android SDK, let's get started with installing Chocolatey. This package manager is recommended by the official React Native documentation for downloading Node and Java. If you already have these tools installed, feel free to skip this step. To install Chocolatey, simply run the following command in your Windows PowerShell window:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
This will get Chocolatey installed and set your environment variables.
Step 2: Install Java
Next, we'll install Java using Chocolatey. If you already have Java installed, skip this step. Run the following command in your command prompt to install Node and Java:
choco install -y nodejs.install openjdk8
Make sure to set your JAVA_HOME environment variable if it's not already set.
Step 3: Install SDK Manager
Now that we have Chocolatey and Java installed, let's move on to installing the Android SDK Manager. Visit the official site and download the sdkmanager compressed file. Unzip the folder in a directory of your choice (e.g., C:\Android).
Step 4: Set Environment Variables
Create a new environment variable called ANDROID_HOME and set it to the path of the directory you created in Step 3 (e.g., C:\Android). Add the following directories to your Path environment variable:
- C:\Android\cmdline-tools\4.0\bin
- C:\Android\platform-tools
Step 5: Install Android SDK Packages
Using the SDK Manager, install the required packages via the sdkmanager command. Follow these steps:
- Install Platform Tools (ADB & Fastboot): Run the following command to install platform-tools:
`
sdkmanager "platform-tools"
`
- Install Platform: Use the following command to install the Android 10 (API level 30) package:
`
sdkmanager "platforms;android-30"
`
- Add System Image: Install a system image using the following command:
`
sdkmanager "system-images;android-30;google_apis;x86_64"
`
- Install Build Tools: Use the following command to install build-tools 30.0.3:
`
sdkmanager "build-tools;30.0.3"
`
- Install Emulator (Optional): If you want to run your apps inside an emulator, follow these steps:
- Install Emulator: Run the following command:
`
sdkmanager --channel=3 emulator
`
- Create emulator: Use the following commands to create an emulator:
`
avdmanager create avd -n em30 -k "system-images;android-30;google_apis;x86_64" -g "google_apis"
avdmanager create avd -n em30ps -k "system-images;android-30;google_apis_playstore;x86_64"
`
- Add emulator path in Path environment variable.
- List emulator devices installed: Run the following command:
`
emulator -list-avds
`
- Run emulator: Use the following command to run an emulator:
`
emulator -avd em30
`
Conclusion
Congratulations! You have successfully set up your Android SDK and are ready to start building and running React Native apps. With these steps, you'll be able to install the required packages and environment variables for swift app development.