opencv/platforms/android/build_aar.sh
Alexander Smorkalov 8850a8219e
Merge pull request #24956 from asmorkalov:as/android_build_offline
Added offline option for Android builds #24956

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-02-05 11:57:16 +03:00

47 lines
1.4 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}}}
OPENCV_GRADLE_VERBOSE_OPTIONS=${OPENCV_GRADLE_VERBOSE_OPTIONS:-'-i'}
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 "aar-build"
cp -rp "${SDK_DIR}" "aar-build"
echo "Cloning OpenCV Android SDK ... Done!"
# drop cmake bin name and "bin" folder from path
echo "ndk.dir=${ANDROID_NDK}" > "aar-build/samples/local.properties"
echo "cmake.dir=$(dirname $(dirname $(which cmake)))" >> "aar-build/samples/local.properties"
echo "Run gradle ..."
(cd "aar-build/samples"; ./gradlew ${OPENCV_GRADLE_VERBOSE_OPTIONS} opencv:publishReleasePublicationToMyrepoRepository)
mkdir "maven_repo"
cp -r aar-build/sdk/build/repo/* ./maven_repo/
echo "#"
echo "# Done!"
echo "#"