在Android许可证上构建本机应用失败
我是第一次涉足本机世界,正在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 .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"
的身份执行它以匹配我的环境中的版本,并且经理确实下载了新许可证,但错误仍然存在。
我不知道如何接受上述许可证。有什么建议吗?
回答如下:您可以使用此命令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"