mirror of
https://github.com/opencv/opencv.git
synced 2024-12-14 17:29:17 +08:00
6c57ce9e09
Updated Android samples for modern Android studio. Added OpenCV from Maven support. #24473 Updated samples for recent Android studio: - added namespace field that is required in build.gradle files - replaced _switch_ by _if-else_ because it doesn't work with constants from resources - added missed log library dependency in face-detection/jni/CMakeLists.txt - use local.properties to define NDK location Added support for OpenCV from Maven. Now you can choose 3 possible sources of OpenCV lib in settings.gradle: SDK path, local Maven repository, public Maven repository. (Creating Maven repository from SDK is added here #24456 ) There are differences in project configs for SDK and Maven versions: - different dependencies in build.gradle - different OpenCV library names in CMakeLists.txt - SDK version requires OpenCV_DIR definition Requires: - https://github.com/opencv/ci-gha-workflow/pull/124 - https://github.com/opencv-infrastructure/opencv-gha-dockerfile/pull/26
41 lines
1.1 KiB
Bash
Executable File
41 lines
1.1 KiB
Bash
Executable File
#!/bin/bash -e
|
|
SDK_DIR=$1
|
|
echo "OpenCV Android SDK path: ${SDK_DIR}"
|
|
|
|
ANDROID_HOME=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-${ANDROID_SDK?Required ANDROID_HOME/ANDROID_SDK/ANDROID_SDK_ROOT}}}
|
|
ANDROID_NDK=${ANDROID_NDK_HOME-${ANDROID_NDK:-${NDKROOT?Required ANDROID_NDK_HOME/ANDROID_NDK/NDKROOT}}}
|
|
|
|
echo "Android SDK: ${ANDROID_HOME}"
|
|
echo "Android NDK: ${ANDROID_NDK}"
|
|
|
|
if [ ! -d "${ANDROID_HOME}" ]; then
|
|
echo "FATAL: Missing Android SDK directory"
|
|
exit 1
|
|
fi
|
|
if [ ! -d "${ANDROID_NDK}" ]; then
|
|
echo "FATAL: Missing Android NDK directory"
|
|
exit 1
|
|
fi
|
|
|
|
export ANDROID_HOME=${ANDROID_HOME}
|
|
export ANDROID_SDK=${ANDROID_HOME}
|
|
export ANDROID_SDK_ROOT=${ANDROID_HOME}
|
|
|
|
export ANDROID_NDK=${ANDROID_NDK}
|
|
export ANDROID_NDK_HOME=${ANDROID_NDK}
|
|
|
|
echo "Cloning OpenCV Android SDK ..."
|
|
rm -rf "test-gradle"
|
|
cp -rp "${SDK_DIR}" "test-gradle"
|
|
echo "Cloning OpenCV Android SDK ... Done!"
|
|
|
|
echo "Force Current CMake for Gradle project"
|
|
# drop cmake bin name and "bin" folder from path
|
|
echo "cmake.dir=$(dirname $(dirname $(which cmake)))" > "test-gradle/samples/local.properties"
|
|
echo "Run gradle ..."
|
|
(cd "test-gradle/samples"; ./gradlew -i assemble)
|
|
|
|
echo "#"
|
|
echo "# Done!"
|
|
echo "#"
|