Reputation: 811
Fixed by setting ANDROID_HOME=/opt/android_sdk/
(was ANDROID_HOME=/opt/android_sdk/cmdline-tools/latest/
).
See: https://developer.android.com/tools/variables#envar
I try to set up a command-line only build environment for Android NDK projects, using commandlinetools-linux-11076708_latest
.
I know how to accept the Android SDK licenses "in advance", as described here: https://developer.android.com/studio/projects/install-ndk
However, the license of the NDK seems to be missing. All NDK projects (such as hello-jni from https://github.com/android/ndk-samples) I tried to build fail with:
> com.android.builder.sdk.LicenceNotAcceptedException: Failed to install the following Android SDK packages as some licences have not been accepted.
ndk;27.0.12077973 NDK (Side by side) 27.0.12077973
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
I believe installing the NDK this way is encouraged nowadays, or do I have to install the NDK manually to be able to accept the license?
sdkmanager --licenses
yields:
[=======================================] 100% Computing updates...
All SDK package licenses accepted.
This is how I set up the Android SDK so far (via Docker):
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
openjdk-21-jre \
zip \
wget && \
rm -rf /var/lib/apt/lists/*
RUN cd /opt && \
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip && \
unzip commandlinetools-linux-11076708_latest.zip -d android_sdk && \
cd android_sdk/cmdline-tools && \
mkdir latest && \
mv bin/ lib/ NOTICE.txt source.properties latest/ && \
yes | /opt/android_sdk/cmdline-tools/latest/bin/sdkmanager --licenses
//ENV ANDROID_HOME=/opt/android_sdk/cmdline-tools/latest/
// FIXED:
ENV ANDROID_HOME=/opt/android_sdk/
The <android_sdk>/licenses
directory contains these licenses:
android-googletv-license
android-sdk-arm-dbt-license
android-sdk-license
android-sdk-preview-license
google-gdk-license
mips-android-sysimage-license
Upvotes: 0
Views: 294
Reputation: 11
I have encountered the same problem. For the solution, however, I do not create a latest folder within cmdline-tools. If you rebuild your script like this, it should work:
Unzip: commandlinetools-linux-11076708_latest
Copy the included cmdline-tools
folder to a suitable location. E.g. /home/<your username>/android-sdk/
Open a terminal in the cmdline-tools/bin
directory and execute the following command: sh sdkmanager --licenses --sdk_root=/home/<your username>/android-sdk
The path to sdk_root
is very important here. It must point to the folder before cmdline-tools
. In this example android-sdk
For your script, the ANDROID_HOME
environment variable must point to /home/<your username>/android-sdk
. In your Docker, it points to another location.
Upvotes: 1