From e8032fa8e9becefc1fbb7b674d58f5240905392c Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 21 Oct 2011 08:35:34 +0000 Subject: [PATCH] Fixed Android build with SDK revision 14 --- android/scripts/package.sh | 19 +++++++++++++++---- modules/java/CMakeLists.txt | 12 +++++++++++- modules/java/android/project.properties | 12 ++++++++++++ samples/android/15-puzzle/project.properties | 3 +++ samples/android/face-detection/project.properties | 3 +++ .../android/image-manipulations/project.properties | 3 +++ .../tutorial-0-androidcamera/project.properties | 2 ++ .../android/tutorial-1-addopencv/project.properties | 3 +++ .../tutorial-2-opencvcamera/project.properties | 3 +++ samples/android/tutorial-3-native/project.properties | 2 ++ samples/android/tutorial-4-mixed/project.properties | 3 +++ 11 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 modules/java/android/project.properties create mode 100644 samples/android/15-puzzle/project.properties create mode 100644 samples/android/face-detection/project.properties create mode 100644 samples/android/image-manipulations/project.properties create mode 100644 samples/android/tutorial-0-androidcamera/project.properties create mode 100644 samples/android/tutorial-1-addopencv/project.properties create mode 100644 samples/android/tutorial-2-opencvcamera/project.properties create mode 100644 samples/android/tutorial-3-native/project.properties create mode 100644 samples/android/tutorial-4-mixed/project.properties diff --git a/android/scripts/package.sh b/android/scripts/package.sh index c259393..a941d20 100644 --- a/android/scripts/package.sh +++ b/android/scripts/package.sh @@ -33,7 +33,7 @@ cmake -C "$ANDROID_DIR/CMakeCache.android.initial.cmake" -DARM_TARGET="armeabi-v make -j8 install/strip || exit 1 cd "$PRG_DIR/opencv" -rm -rf doc include src .classpath .project AndroidManifest.xml default.properties share/OpenCV/haarcascades share/OpenCV/lbpcascades share/OpenCV/*.cmake share/OpenCV/OpenCV.mk +rm -rf doc include src .classpath .project AndroidManifest.xml default.properties project.properties share/OpenCV/haarcascades share/OpenCV/lbpcascades share/OpenCV/*.cmake share/OpenCV/OpenCV.mk # armeabi build @@ -67,15 +67,26 @@ for dir in `ls -1` do if [ -f "$dir/default.properties" ] then - HAS_REFERENCE=`cat "$dir/default.properties" | grep -c android.library.reference.1` + HAS_REFERENCE=`cat "$dir/project.properties" | grep -c android.library.reference.1` if [ $HAS_REFERENCE = 1 ] then - echo -n > "$dir/default.properties" + echo -n > "$dir/project.properties" android update project --name "$dir" --target "android-8" --library "../../$OPENCV_NAME" --path "$dir" #echo 'android update project --name "$dir" --target "android-8" --library "../opencv$CV_VERSION" --path "$dir"' fi else - rm -rf "$dir" + if [ -f "$dir/default.properties" ] + then + HAS_REFERENCE=`cat "$dir/default.properties" | grep -c android.library.reference.1` + if [ $HAS_REFERENCE = 1 ] + then + echo -n > "$dir/default.properties" + android update project --name "$dir" --target "android-8" --library "../../$OPENCV_NAME" --path "$dir" + #echo 'android update project --name "$dir" --target "android-8" --library "../opencv$CV_VERSION" --path "$dir"' + fi + else + rm -rf "$dir" + fi fi done diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index 6e4b7ba..c03ec73 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -214,7 +214,17 @@ if(ANDROID) COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/res" COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/gen" DEPENDS ${lib_proj_files} - ) + ) + if (ANT_EXECUTABLE AND ANDROID_EXECUTABLE AND ANDROID_TOOLS_Pkg_Revision GREATER 13) + add_custom_command( + TARGET ${target} + COMMAND ${ANDROID_EXECUTABLE} update lib-project --path "${CMAKE_BINARY_DIR}" + COMMAND ${ANT_EXECUTABLE} debug + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + DEPENDS ${lib_target} + ) + endif() + add_dependencies(${lib_target} ${api_target}) add_dependencies(${target} ${lib_target}) diff --git a/modules/java/android/project.properties b/modules/java/android/project.properties new file mode 100644 index 0000000..863e850 --- /dev/null +++ b/modules/java/android/project.properties @@ -0,0 +1,12 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +android.library=true +# Project target. +target=android-8 diff --git a/samples/android/15-puzzle/project.properties b/samples/android/15-puzzle/project.properties new file mode 100644 index 0000000..fb3ea1f --- /dev/null +++ b/samples/android/15-puzzle/project.properties @@ -0,0 +1,3 @@ +android.library.reference.1=../../../android/build +# Project target. +target=android-8 diff --git a/samples/android/face-detection/project.properties b/samples/android/face-detection/project.properties new file mode 100644 index 0000000..74bb01a --- /dev/null +++ b/samples/android/face-detection/project.properties @@ -0,0 +1,3 @@ +android.library.reference.1=../../OpenCV-2.3.1 +# Project target. +target=android-8 diff --git a/samples/android/image-manipulations/project.properties b/samples/android/image-manipulations/project.properties new file mode 100644 index 0000000..fb3ea1f --- /dev/null +++ b/samples/android/image-manipulations/project.properties @@ -0,0 +1,3 @@ +android.library.reference.1=../../../android/build +# Project target. +target=android-8 diff --git a/samples/android/tutorial-0-androidcamera/project.properties b/samples/android/tutorial-0-androidcamera/project.properties new file mode 100644 index 0000000..32299c2 --- /dev/null +++ b/samples/android/tutorial-0-androidcamera/project.properties @@ -0,0 +1,2 @@ +# Project target. +target=android-8 diff --git a/samples/android/tutorial-1-addopencv/project.properties b/samples/android/tutorial-1-addopencv/project.properties new file mode 100644 index 0000000..fb3ea1f --- /dev/null +++ b/samples/android/tutorial-1-addopencv/project.properties @@ -0,0 +1,3 @@ +android.library.reference.1=../../../android/build +# Project target. +target=android-8 diff --git a/samples/android/tutorial-2-opencvcamera/project.properties b/samples/android/tutorial-2-opencvcamera/project.properties new file mode 100644 index 0000000..fb3ea1f --- /dev/null +++ b/samples/android/tutorial-2-opencvcamera/project.properties @@ -0,0 +1,3 @@ +android.library.reference.1=../../../android/build +# Project target. +target=android-8 diff --git a/samples/android/tutorial-3-native/project.properties b/samples/android/tutorial-3-native/project.properties new file mode 100644 index 0000000..32299c2 --- /dev/null +++ b/samples/android/tutorial-3-native/project.properties @@ -0,0 +1,2 @@ +# Project target. +target=android-8 diff --git a/samples/android/tutorial-4-mixed/project.properties b/samples/android/tutorial-4-mixed/project.properties new file mode 100644 index 0000000..fb3ea1f --- /dev/null +++ b/samples/android/tutorial-4-mixed/project.properties @@ -0,0 +1,3 @@ +android.library.reference.1=../../../android/build +# Project target. +target=android-8 -- 2.7.4