React Native: fix error: Failed to install the following Android SDK packages as some licences have not been accepted


Sample error:

D:\VueNative\demo>react-native run-android
(node:10776) Warning: Accessing non-existent property 'padLevels' of module expo
rts inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
info JS server already running.
info Building and installing the app on the device (cd android && gradlew.bat ap
p:installDebug)...

> Configure project :app
File C:\Users\Administrator\.android\repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\Admi
nistrator\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in C:\Users\Administrat
or\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Platform 28 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not
 been accepted.
     build-tools;28.0.3 Android SDK Build-Tools 28.0.3
     platforms;android-28 Android SDK Platform 28
  To build this project, accept the SDK license agreements and install the missi
ng components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to anot
her, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: C:\Users\Administrator\AppData\Local\Android\Sdk

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with
Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:comman
d_line_warnings

BUILD FAILED in 2s
error Could not install the app on the device, read the error above for details.

Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag
for more details.

In error message we see:

     build-tools;28.0.3 Android SDK Build-Tools 28.0.3
     platforms;android-28 Android SDK Platform 28

Now we must install Android SDK Platform 28:

Step 1: In Android studio, go to menu File -> Settings

Step 2:

install Android SDK Platform 28 step 2

Step 3:

install Android SDK Platform 28 step 3

Clck OK

Step 4:

install Android SDK Platform 28 step 4

Click Accept then Next

Step 5:

install Android SDK Platform 28 step 5

Wait for some minutes then Click Finish

Leave a Reply