Skip to content

FindJNI: replace CMAKE_ANDROID_API by CMAKE_SYSTEM_VERSION

Sergiu Deitsch requested to merge sergiud/cmake:findjni-system-version into master

In !7069 (merged) we used CMAKE_ANDROID_API to check the Android API level. However, CMAKE_SYSTEM_VERSION is the authoritative value.

When cross-compiling for Android, an unset CMAKE_ANDROID_API can result in failure to locate JNI because the NativeHelper component cannot be found. In this case, the component is falsely assumed to be available by default (and thus required) since the comparison against an unset CMAKE_ANDROID_API variable evaluates to true. Use CMAKE_SYSTEM_VERSION to determine the Android API level instead.

Issue: #23830 (closed)
Backport: release
Topic-rename: FindJNI-android-api

Edited by Brad King

Merge request reports