August 2, 2017

自動接受 Android SDK 授權

自動接受 Android SDK 授權

今天在用 React Native 開發 Android 版本時,剛遇到了一點 SDK 授權的問題,筆記一下。

以下為錯誤訊息內容。

You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 26].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

根據上面的錯誤提示,輸入以下就能列出所有可安裝的 Android SDK 版本。

$ android list sdk -a

Packages available for installation or update: 185
   1- Android SDK Tools, revision 25.2.5
   2- Android SDK Platform-tools, revision 26
   3- Android SDK Build-tools, revision 26.0.1
   4- Android SDK Build-tools, revision 26
   5- Android SDK Build-tools, revision 25.0.3
   6- Android SDK Build-tools, revision 25.0.2
   7- Android SDK Build-tools, revision 25.0.1
   8- Android SDK Build-tools, revision 25
   9- Android SDK Build-tools, revision 24.0.3
  10- Android SDK Build-tools, revision 24.0.2
  11- Android SDK Build-tools, revision 24.0.1
  12- Android SDK Build-tools, revision 24
  13- Android SDK Build-tools, revision 23.0.3
  14- Android SDK Build-tools, revision 23.0.2

可以看到列出了許多版本,再輸入以下指令並選擇正確要安裝的版本編號。

$ android update sdk -a --no-ui --filter 3  # 3 為 list 中顯示的編號

References