反应本机|无法安装该应用程序。请使用SDK Manager接受所有必要的SDK许可

时间:2019-07-20 12:14:47

标签: android android-studio react-native

我试图开始运行我的React Native项目。但是在运行import json with open('12.1 world.json',encoding="utf-8-sig",errors='ignore') as f: data = [json.loads(line,strict=False) for line in f] 命令时出现此错误。我尝试了很多在网上找到的解决方案,但是都没有用。

react-native run-android

3秒内失败


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

如何解决此问题。

预先感谢您:)

7 个答案:

答案 0 :(得分:45)

在您的Android Studio中转到配置> SDK管理器

选择 SDK工具标签并安装 Google Play许可库

答案 1 :(得分:4)

如果您使用的是ubuntu,请执行以下操作:-

1>导航到Android Studio:-〜/ Library / Android / sdk / tools / bin

2>运行以下命令:-sdkmanager --licenses

答案 2 :(得分:2)

对于Linux用户::

  1. 导航至路径:: cd ~/Library/Android/sdk/tools/bin/或Android> sdk>工具> bin
  2. 的路径
  3. 然后按以下方式运行sdkmanager: ./sdkmanager --licenses

并接受您尚未接受(但需要)的许可证。

有关更多详细信息,请参见Android Studio documentation

答案 3 :(得分:0)

打开Android Studio,然后单击齿轮图标(配置)。按SDK Manager选项。应该显示三个选项卡,然后按“ SDK工具”选项卡。之后,请确保更新了Android SDK生成工具,Android SDK平台工具和Android SDK工具。检查它们,然后按“应用”。

完成后,转到终端并导航到您的RN项目。运行Array (Int, Int) Word8,然后运行react-native start

答案 4 :(得分:0)

已通过下载sdk 28(而不是29 ly for android 10 ....

所以请检查下载了哪个版本的sdk,然后下载28个版本的sdk

答案 5 :(得分:0)

在新环境中启动新的本机项目时,我多次陷入这个问题。在大多数情况下,运行sdkmanager --licenses不会这样做,因为它只会表明您已经接受了所有许可证。

我的本​​地人这样说:

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

但是,我注意到在Android Studio> SDK Manager> SDK Tools中,我没有安装28.0.3构建工具。选中“显示软件包详细信息”,然后在“ SDK构建工具”下,确保安装了正确的构建工具版本。

添加正确的版本后,我可以再次运行sdkmanager --licenses,接受许可证,并成功启动我的RN项目。

答案 6 :(得分:0)

运行react-native run-android时遇到相同的问题

导航到路径Android/sdk/tools/bin/并运行此命令并不能解决我的问题。

./sdkmanager --licenses

此命令给出此错误

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

我的解决方案:-

注意:我没有导出Java路径或提供Java路径,只是安装了Java和javac。我下载了包含所有SDK的android studio软件包。在执行以下步骤时,单击android studio的“工具”选项卡之前,我还没有看到“ SDK管理器”和“ AVD管理器”选项卡

第1步:打开Android并转到文件/设置,然后单击Android SDK

enter image description here

第2步:首次打开时,仅安装了SDK API级别30,然后选择API级别29并选择Apply。它将下载API 29。

enter image description here

第3步:转到中间的“ SDK工具”标签,选择“ Android SDK命令行工具”,然后单击“应用”,然后下载

enter image description here

步骤4:重新启动系统。然后,您将看到SDK Manager选项卡,然后可以运行您的项目。