在Android许可证上构建React Native App失败

时间:2019-10-04 21:01:58

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

我第一次涉足本机世界,并且我尝试在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"的身份执行它以匹配环境中的版本,经理确实下载了新许可证,但错误仍然存​​在。

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

3 个答案:

答案 0 :(得分:0)

您可以使用此命令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"

答案 1 :(得分:0)

打开Android Studio-> SDK管理器,然后选择Android 8.1(Oreo)按“确定”,然后接受许可并安装

答案 2 :(得分:0)

对我来说

  • (对我而言)ANDROID_HOME的值是D:\ Android,并且CLI会在路径的末尾自动添加“ platform-tools”
  • 在许可证文件夹中,我已删除所有许可证并运行是|。 sdkmanager-许可证
  • 我将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 Player
  • adb connect 127.0.0.1:62001
  • adb反向tcp:8081 tcp:8081
  • react-native run-android

对我有用。