[Android] buildsystem: get the NDK path and full version
Steve Lhomme
git at videolan.org
Fri Feb 13 07:51:44 UTC 2026
vlc-android | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Jun 23 15:37:36 2025 +0200| [8329091e1ac6d5105076145fab598e54b25ea4f8] | committer: Steve Lhomme
buildsystem: get the NDK path and full version
Otherwise stick to the version from the Dockers and let gradle handle the path.
If we want gradle to use the NDK we used to build libvlc/medialibrary we need
to set the full ndkVersion and the path to that NDK.
The default NDK version 28.2.13676358 correspond to the one we have the current
Docker image.
> https://code.videolan.org/videolan/vlc-android/commit/8329091e1ac6d5105076145fab598e54b25ea4f8
---
application/vlc-android/build.gradle | 3 +++
build.gradle | 6 ++++++
buildsystem/compile.sh | 5 ++++-
medialibrary/build.gradle | 6 ++++++
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/build.gradle b/application/vlc-android/build.gradle
index 62956446f9..af5e466e24 100644
--- a/application/vlc-android/build.gradle
+++ b/application/vlc-android/build.gradle
@@ -41,6 +41,9 @@ android {
testInstrumentationRunnerArguments clearPackageData: 'true'
vectorDrawables.useSupportLibrary = true
+ ndkVersion = rootProject.ext.toolchainNdkVersion
+ if (rootProject.ext.tooclchainNdkPath != null)
+ ndkPath = rootProject.ext.tooclchainNdkPath
}
testOptions {
diff --git a/build.gradle b/build.gradle
index 5d54d7aa52..1638e85aab 100644
--- a/build.gradle
+++ b/build.gradle
@@ -50,6 +50,12 @@ ext {
libvlcVersion = vlcMajorVersion == 3 ? '3.6.5' :'4.0.0-eap23'
medialibraryVersion = '0.13.16' + (vlcMajorVersion == 3 ? '' : '-vlc4') + '-rc20'
buildToolsVersion = vlcMajorVersion == 3 ? '35.0.0' : '35.0.0'
+ Properties properties = new Properties()
+ properties.load(project.rootProject.file('local.properties').newDataInputStream())
+ // default ndkVersion in android_plugin_version in 8.9.1: 27.0.12077973
+ // VLC 3 needs to stick to NDK21 which is the last one supporting Android API 17
+ toolchainNdkVersion = properties.getProperty('android.ndkFullVersion') ?: (vlcMajorVersion == 3 ? '21.4.7075529' : '28.2.13676358')
+ tooclchainNdkPath = properties.getProperty('android.ndkPath')
targetSdkVersion = 36
compileSdkVersion = 36 // Dockers: 3.0=36 / 4.0=36
desugarLib = '2.0.4'
diff --git a/buildsystem/compile.sh b/buildsystem/compile.sh
index eac53a2a33..dbebde52bf 100755
--- a/buildsystem/compile.sh
+++ b/buildsystem/compile.sh
@@ -203,6 +203,8 @@ init_local_props() {
echo_props() {
echo "sdk.dir=$ANDROID_SDK"
echo "android.ndkPath=$ANDROID_NDK"
+ NDK_FULL_VERSION=$(grep -o '^Pkg.Revision.*[0-9]*.*' $ANDROID_NDK/source.properties |cut -d " " -f 3)
+ echo "android.ndkFullVersion=$NDK_FULL_VERSION"
if [ $(command -v cmake) >/dev/null 2>&1 ]; then
# prefix of the cmake installation, not the cmake path or the dir that contains the cmake executable
echo "cmake.dir=$(dirname $(dirname $(command -v cmake)))"
@@ -245,8 +247,9 @@ init_local_props() {
while IFS= read -r LINE || [ -n "$LINE" ]; do
line_sdk_dir="${LINE#sdk.dir=}"
line_ndk_dir="${LINE#android.ndkPath=}"
+ line_ndk_version="${LINE#android.ndkFullVersion=}"
line_cmake_dir="${LINE#cmake.dir=}"
- if [ "x$line_sdk_dir" = "x$LINE" ] && [ "x$line_ndk_dir" = "x$LINE" ] && [ "x$line_cmake_dir" = "x$LINE" ]; then
+ if [ "x$line_sdk_dir" = "x$LINE" ] && [ "x$line_ndk_dir" = "x$LINE" ] && [ "x$line_ndk_version" = "x$LINE" ] && [ "x$line_cmake_dir" = "x$LINE" ]; then
echo "$LINE"
fi
done <"$1" >"$temp_props"
diff --git a/medialibrary/build.gradle b/medialibrary/build.gradle
index cc155e4c6e..e603f6cb64 100644
--- a/medialibrary/build.gradle
+++ b/medialibrary/build.gradle
@@ -34,6 +34,12 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
+ defaultConfig {
+ ndkVersion = rootProject.ext.toolchainNdkVersion
+ if (rootProject.ext.tooclchainNdkPath != null)
+ ndkPath = rootProject.ext.tooclchainNdkPath
+ }
+
sourceSets {
main {
jniLibs.srcDir 'jni/libs' // Where generated .so files are placed.
More information about the Android
mailing list