Android で ビルド失敗するとき

  • 0
    Like
  • 0
    Comment

    ライセンスへの同意が完了していない場合の対処

    ビルド時にライセンスへの同意が完了していないと怒られた場合に、CLI上で解決する方法。

    問題

    下記コマンドを実行した際に失敗した。

    react-native run-android
    

    エラー内容

    FAILURE: Build failed with an exception.                                                            
    
    * What went wrong:                                                                                  
    A problem occurred configuring project ':app'.                                                      
    > Could not resolve all dependencies for configuration ':app:_debugApk'.                            
       > A problem occurred configuring project 'XXXXX'.                            
          > You have not accepted the license agreements of the following SDK components:               
            [Android SDK Build-Tools 25.0.2].                                                           
            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
    

    対応

    下記コマンドで、OK

    sdkmanager --license
    

    あとは、表示されるメッセージに従う

    help の内容

    sdkmanager --licenses [<common args>]
    
    With --licenses, show and offer the option to accept licenses for all
         available packages that have not already been accepted.