This short and straightforward article shows you how to fix an error that often happens when working with React Native.
When trying to run a React Native app on a virtual Android device with the following:
npm run Android
You may face this error:
error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: “$ANDROID_HOME/tools/bin/sdkmanager –licenses”.
There is a couple of different ways to get rid of the annoying error. If the first one doesn’t work as expected, you can try the other one.
Using Command Line
To solve the problem, you need to accept all required Android SDK licenses. Just execute one of the following commands.
cmd.exe /C"%ANDROID_HOME%\tools\bin\sdkmanager.bat --licenses"
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
The process might take a few seconds to complete. When it’s done, you’ll see something similar to this:
Using Android Studio
1. Open your Android Studio and go to SDK Manager:
2. In the Android SDK section, select the SDK Tools tab then check the checkbox next to Google Play Licensing Library.
3. Click on the OK button to start installing.
Together we’ve solved a problem that commonly occurs when setting up a development environment. Now it’s gone and you can continue learning more new and exciting stuff about React Native by taking a look at the following articles:
- Using Image Picker and Camera in React Native (Expo)
- How to render HTML content in React Native
- React Native FlatList: Tutorial and Examples
- How to implement tables in React Native
- Implementing a Date Time picker in React Native
- Using Switch component in React Native (with Hooks)