Close

2023-09-16

You have not accepted the license agreements of the following SDK components.

You have not accepted the license agreements of the following SDK components.

You have not accepted the license agreements of the following SDK components: [Android SDK Platform 23, Android SDK Build-Tools 23.0.1]. 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

Issue

This issue occurs because Gradle cannot find the accepted licenses in the expected directory. Accepting licenses through the command line should create a “licenses” directory in the Android SDK home directory. Since the licenses directory is missing, you’re seeing this error.

Here’s how you can resolve this issue:

Step 1: Locate the Android SDK Home Directory

First, you need to locate the Android SDK home directory. It seems you have checked ~/.android and /opt/android-sdk, but it might be found elsewhere. You can check the ANDROID_SDK_ROOT or ANDROID_HOME Environment variable to find the SDK location:

echo $ANDROID_SDK_ROOT
# or
echo $ANDROID_HOME

Step 2: Create Licenses Directory

Once you have located the Android SDK home directory, create a “licenses” directory inside it:

mkdir /path/to/android-sdk/licenses

Step 3: Accept Licenses

Now, use the sdkmanager to accept the licenses again. Navigate to the tools/bin directory inside the Android SDK home directory and run:

./sdkmanager --licenses

Accept the licenses as prompted. This should create the necessary files inside the “licenses” directory.

Step 4: Manually Add License Files (If Necessary)

You can manually create the license files if the above step does not create them. Inside the “licenses” directory, create a file named android-sdk-license and add the license hash for the respective components. The content of the file should be:

8933bad161af4178b1185d1a37fbf41ea5269c55
d56f5187479451eabf01fb78af6dfcb131a6481e
24333f8a63b6825ea9c5514f83c2829b004d1fee

Step 5: Build with Gradle

Now, try building your project with Gradle again. It should be able to find the accepted licenses and proceed with the build.

./gradlew build