Problem with building for android O(api 26)

So I upgraded my config from android-25(which worked good) to android-26:

 - ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --filter "tools,android-26,build-tools-26.0.0,platform-tools,android-26,extra-google-m2repository,extra-android-m2repository,extra-android-support,extra-google-google_play_services"

With this config I receive following build problem:

File /home/ubuntu/.android/repositories.cfg could not be loaded.
Checking the license for package SDK Patch Applier v4 in /usr/local/android-sdk-linux/licenses
Warning: License for package SDK Patch Applier v4 not accepted.
Checking the license for package Google Repository in /usr/local/android-sdk-linux/licenses
Warning: License for package Google Repository not accepted.

FAILURE: Build failed with an exception.

Looks like it is problem with new play services 11.0.1

Its not just Android O for me, this also happened when updating to play services 11.0.1 while still on API 25. More of the error:

  • What went wrong:
    A problem occurred configuring project ‘:app’.

You have not accepted the license agreements of the following SDK components:
[SDK Patch Applier v4, Google Repository].

Does anyone have a solution yet?

Does this work for you? Need to accept license agreement for Android tools?

Why isn’t there a better solution for this?

Why does the upgrade require it and not the previously existing version?

Copying the local licenses to the app’s directory to “accept” the licenses doesn’t seem like a proper solution.

Everything started work fine for me with same config for play services 11.0.2