Android:You have not accepted the license agreements of the following SDK components

Published on:
Last updated:

This post is also available in: 日本語 (Japanese)

Androidスマートフォンアプリを開発している際に下記のようなエラーに遭遇しました。
今回の私の場合はReactNativeで開発していて、 react-native-firebase というライブラリの導入に伴って起こったようですが、他のケース(Google Play Serviceを使ったり等)でも同様のエラーが出る可能性があるかと思います。

Android SDK Tools>SDK Manager を起動して(Windowsの場合は管理者権限で)、下記のエラー中の [Android SDK Build-Tools 25.0.2, Android SDK Platform 25] の部分に対応するSDKのバージョンをインストールすることで軽く対処できると思っていたら、どうも解決されなかったので、対処方法をメモ代わりに書いています。

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-firebase'.
      > You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 25.0.2, Android SDK Platform 25].
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

調べてみると、コマンドラインから以下のように打つ方法もあるらしいですが、

sdkmanager --licenses

普通に、Android Studioを立ち上げて、Android Studio>Configure>SDK Manager(もしくは、Appearance & Behavior > System Settings > Android SDK)から、該当するSDKをインストールすることで、エラーが無くなりました。
ちなみに、Firebaseと連携させる場合には
Extras > Google Play services
SDK Tools > Support Repository > Android Support Repository
SDK Tools > Support Repository > Google Repository
をインストールしておくと楽に開発できるかと思います。

About
Kuniyoshi Takemoto is the founder of Amelt.net LLC, and editor of this blog(www.amelt.net).Learn more and follow me on LinkedIn.