Error while packaging project for Android platform

I was trying to package the AR template for Android but I’m always getting this error

UATHelper: Packaging (Android (ETC1)): WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1. UATHelper: Packaging (Android (ETC1)): Android SDK Build Tools 26.0.2 will be used. UATHelper: Packaging (Android (ETC1)): To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools. PackagingResults: Warning: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1. UATHelper: Packaging (Android (ETC1)): File C:\Users\Mihai Andrei\.android\repositories.cfg could not be loaded. UATHelper: Packaging (Android (ETC1)): Checking the license for package Android SDK Build-Tools 26.0.2 in D:\CodeWorks\android-sdk-windows\licenses UATHelper: Packaging (Android (ETC1)): Warning: License for package Android SDK Build-Tools 26.0.2 not accepted. UATHelper: Packaging (Android (ETC1)): FAILURE: Build failed with an exception. UATHelper: Packaging (Android (ETC1)): * What went wrong: UATHelper: Packaging (Android (ETC1)): A problem occurred configuring project ':app'. UATHelper: Packaging (Android (ETC1)): > You have not accepted the license agreements of the following SDK components: UATHelper: Packaging (Android (ETC1)): [Android SDK Build-Tools 26.0.2]. UATHelper: Packaging (Android (ETC1)): 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. UATHelper: Packaging (Android (ETC1)): 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 UATHelper: Packaging (Android (ETC1)): * Try: UATHelper: Packaging (Android (ETC1)): Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. UATHelper: Packaging (Android (ETC1)): * Get more help at https://help.gradle.org UATHelper: Packaging (Android (ETC1)): BUILD FAILED in 1m 35s PackagingResults: Warning: License for package Android SDK Build-Tools 26.0.2 not accepted. UATHelper: Packaging (Android (ETC1)): ERROR: cmd.exe failed with args /c "D:\Epic Games\Unreal Projects\BroBotsApp\Intermediate/Android/APK\gradle\rungradle.bat" :app:assembleDebug UATHelper: Packaging (Android (ETC1)): (see C:\Users\Mihai \AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+Epic+Games+UE_4.21\Log.txt for full exception trace) PackagingResults: Error: cmd.exe failed with args /c "D:\Epic Games\Unreal Projects\BroBotsApp\Intermediate/Android/APK\gradle\runAndreigradle.bat" :app:assembleDebug UATHelper: Packaging (Android (ETC1)): AutomationTool exiting with ExitCode=1 (Error_Unknown) UATHelper: Packaging (Android (ETC1)): BUILD FAILED PackagingResults: Error: Unknown Error

I’ve tried to reinstall CodeWorks, uninstalled it and then installed from the Engine/Extras, I tried to install Android Studio but nothing… here are some screenshots with the error and my settings:

Andreutzu31, Did you find solution?

From the command line, go to android-sdk-windows\tools\bin and run the following command:

sdkmanager.bat --update

It should update and accept the pending licenses.

This has been fixed in 4.22, but the workaround for 4.21 is rather simple:

  1. Download 4.22 (preview or release doesn’t matter in case you’re reading this after 4.22 release).
  2. Find package.xml at \UE_4.22\Engine\Source\ThirdParty\Android
  3. Replace package.xml at \UE_4.21\Engine\Source\ThirdParty\Android
  4. You should now be able to “Accept SDK license” again in Project settings → Android

This is the answer! Thank you for helping with this.