【问题标题】:Building react native app fails on android licenses在 android 许可证上构建反应原生应用程序失败
【发布时间】:2020-02-03 04:34:48
【问题描述】:

我第一次进入 react native 世界,我正在尝试按照this article 从头开始​​设置 Windows 开发环境。在我尝试运行react-native run-android 之前一切正常。我已经接受了sdkmanager --licenses 的所有许可证,但我仍然收到许可证错误:

> Configure project :app
Checking the license for package Android SDK Build-Tools 27.0.3 in C:\Program Files\Android\Android Studio\licenses
Warning: License for package Android SDK Build-Tools 27.0.3 not accepted.
Checking the license for package Android SDK Platform 27 in C:\Program Files\Android\Android Studio\licenses
Warning: License for package Android SDK Platform 27 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.
     platforms;android-27 Android SDK Platform 27
     build-tools;27.0.3 Android SDK Build-Tools 27.0.3
  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

然后我找到了this comment,其中用户建议使用以下命令:$ANDROID_HOME/tools/bin/sdkmanager "build-tools;26.0.1" "platforms;android-26"。我以sdkmanager.bat "platforms;android-27" "build-tools;27.0.3" 执行它以匹配我环境中的版本,并且经理确实下载了新许可证,但错误仍然存​​在。

我不知道如何接受上述许可。有什么建议吗?

【问题讨论】:

    标签: android node.js react-native android-studio build


    【解决方案1】:

    你可以使用这个命令yes | sdkmanager --licenses

    或者你可以在mac上使用这个命令yes | sudo ~/Library/Android/sdk/tools/bin/sdkmanager --licenses

    或者对于 Windows:cmd.exe ""/K"%LocalAppData%\Android\sdk\tools\bin\sdkmanager.bat --licenses"

    【讨论】:

    • sdkmanager --licences 表示没有许可接受。
    • 您需要仔细检查 $ANDROID_HOME PATH 。尝试通过输入终端 echo $ANDROID_HOME 来回显 ANDROID_HOME,然后试试这个是 | $ANDROID_HOME/tools/bin/sdkmanager --licenses
    • 我告诉你,它总是给我“接受所有 SDK 包许可证。”
    【解决方案2】:

    打开 Android Studio->SDK Manager 然后选择 Android 8.1 (Oreo) 按 OK 然后接受许可并安装

    【讨论】:

    • 我的 Android Studio 中已经安装了从 4.4 到 10.0 的所有 SDK。
    • 那请尝试卸载一个包重新安装
    【解决方案3】:

    对我来说:

    • ANDROID_HOME 值(对我而言)是 D:\Android,CLI 会在路径末尾自动添加“平台工具”
    • 在许可证文件夹中,我已将其全部删除并运行yes | sdkmanager --licenses
    • 我将 licenses 文件夹复制到 platform-tools 目录中
    • 我再次检查 JAVA_HOME 和 ANDROID_HOME 的值是否正确。我必须重新启动计算机才能应用此更改

    如果您在开始时遇到 REGEX 错误(如 Expo),只需进入 node_modules\metro-config\src\defaults\blacklist.js 并更改 sharedBlacklist 的第一行:

    */node_modules[\/\\]react[\/\\]dist[\/\\].*/,*
    

    CLI 发出尖叫声,因为每个括号中缺少第一个 \。

    在 CLI 中:

    我使用 Nox Player 运行项目。

    • 启动 Nox 播放器
    • adb 连接 127.0.0.1:62001
    • adb 反向 tcp:8081 tcp:8081
    • react-native run-android

    这对我有用。

    【讨论】:

      猜你喜欢
      • 2022-08-19
      • 1970-01-01
      • 2019-11-30
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-05
      • 1970-01-01
      相关资源
      最近更新 更多