React Native | Failed to install the app. Please accept all necessary SDK licenses using SDK Manager

允我心安 提交于 2020-12-29 02:51:16

问题


I was trying to start running my react native project. But I'm getting this error while running the react-native run-android command. I tried a bunch of solutions that I found online but neither of them worked.


info Starting JS server...
info Installing the app...

> Configure project :app
Checking the license for package Android SDK Build-Tools 28.0.3 in /home/dipanshuchaubey/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 /home/dipanshuchaubey/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 missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: /home/dipanshuchaubey/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

BUILD FAILED in 3s

error Failed to install the app. Please accept all necessary SDK licenses using SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses". Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

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 missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: /home/dipanshuchaubey/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

BUILD FAILED in 3s

at checkExecSyncError (child_process.js:616:11)
at execFileSync (child_process.js:634:15)
at runOnAllDevices (/home/dipanshuchaubey/Documents/practice/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
at buildAndRun (/home/dipanshuchaubey/Documents/practice/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:137:41)
at /home/dipanshuchaubey/Documents/practice/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:103:12
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async Command.handleAction (/home/dipanshuchaubey/Documents/practice/native/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:160:7)

How to fix this.

Thank you in Advance :)


回答1:


Go to Configure>SDK Manager in your Android Studio.

Select SDK Tools tab and install Google Play Licensing Library




回答2:


For linux Users::

  1. Navigate TO PATH :: cd ~/Library/Android/sdk/tools/bin/ OR PATH OF YOUR Android > sdk > tools > bin
  2. Then Run the sdkmanager as follows: ./sdkmanager --licenses

And accept the licenses you did not accept yet (but need to).

For more details see the Android Studio documentation




回答3:


If u are using ubuntu please do this :--

1> Navigate to Android studio:- ~/Library/Android/sdk/tools/bin

2> Run this command:- sdkmanager --licenses




回答4:


Open Android Studio, then click the gear icon (Configure). Press the SDK Manager option. Three tabs should be displayed, press the SDK Tools tab. After that, make sure that Android SDK Build-Tools, Android SDK Platform-Tools and Android SDK Tools are updated. Check them and press Apply.

When done, go to the terminal and navigate towards your RN project. Run react-native start then react-native run-android




回答5:


Have solved this by download the sdk 28 instead 29 which current ly for the android 10....

so check which version of the sdk is downloaded and download the 28 version of the sdk




回答6:


I have stumbled into this problem many times when starting up a new react-native project in a new environment. Most of the times, running sdkmanager --licenses isn't gonna do it because it will simply say you have already accepted all the licenses.

My react native was saying this:

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-29 Android SDK Platform 29

However, in Android Studio > SDK Manager > SDK Tools, I noticed that I didn't have the 28.0.3 build-tools installed. Check "Show Package Details" and under SDK Build Tools, make sure you have the correct build-tools version installed.

After adding the correct version, I could again run sdkmanager --licenses, accept the licenses, and successfully start my RN project.




回答7:


Got same issue while running react-native run-android

Navigating to the path Android/sdk/tools/bin/ and running this command doesn't fix the issues for me.

./sdkmanager --licenses

this command give this errors

sdk manager license Exception in thread "main" java.lang.NoClassDefFoundError:

My Solution:-

NOTE: i did not export java path or giving java path, just installed java and javac. I downloaded android studio package which includes all sdk. Before doing below steps when click on Tools tab of android studio i haven't seen the SDK Manager and AVD Manager Tab

Step 1: Open Android and Go to File/Setting and click Android SDK

Step 2: When i open first only SDK API level 30 was installed, then select API level 29 and select Apply. It downloads the API 29.

Step 3: Go to SDK Tools Tab which is in middle, select Android SDK Command Line Tools and Apply then Download

Step 4: Restart your system. Then you will see SDK Manager Tab and you can run your project.



来源:https://stackoverflow.com/questions/57124607/react-native-failed-to-install-the-app-please-accept-all-necessary-sdk-licens

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!