From 87331ca1a0ab3655ff3118e9bb8e44958e19b73a Mon Sep 17 00:00:00 2001 From: anders-nylander <101791049+anders-nylander@users.noreply.github.com> Date: Thu, 25 May 2023 17:29:14 +0200 Subject: [PATCH] Merge pull request #21736 from anders-nylander:fix_android_sdk_tools_dependency Android: don't require deprecated tools #21736 Checking for these deprecated is no longer necessary, and infact broken on fresh Android SDK installs. Remove the check. resolves #21735 ### 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 - [x] 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 --- cmake/android/OpenCVDetectAndroidSDK.cmake | 36 ++++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/cmake/android/OpenCVDetectAndroidSDK.cmake b/cmake/android/OpenCVDetectAndroidSDK.cmake index 3431d4aff8..d9853ae4de 100644 --- a/cmake/android/OpenCVDetectAndroidSDK.cmake +++ b/cmake/android/OpenCVDetectAndroidSDK.cmake @@ -170,27 +170,29 @@ endmacro() # ocv_detect_android_sdk_build_tools if(BUILD_ANDROID_PROJECTS) ocv_detect_android_sdk() - ocv_detect_android_sdk_tools() ocv_detect_android_sdk_build_tools() - if(ANDROID_SDK_TOOLS_VERSION VERSION_LESS 14) - message(FATAL_ERROR "Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.\n" - "${__msg_BUILD_ANDROID_PROJECTS}") - endif() + if(NOT ANDROID_SDK_BUILD_TOOLS_VERSION VERSION_LESS 26.0.2) + # https://developer.android.com/studio/releases/gradle-plugin.html + message(STATUS "Android SDK Build Tools: Gradle 3.0.0+ builds support is available") + ocv_update(ANDROID_PROJECTS_SUPPORT_GRADLE ON) + else() + ocv_detect_android_sdk_tools() - if(NOT ANDROID_SDK_TOOLS_VERSION VERSION_LESS 25.3.0) - message(STATUS "Android SDK Tools: Ant (Eclipse) builds are NOT supported by Android SDK") - ocv_update(ANDROID_PROJECTS_SUPPORT_ANT OFF) - if(NOT ANDROID_SDK_BUILD_TOOLS_VERSION VERSION_LESS 26.0.2) - # https://developer.android.com/studio/releases/gradle-plugin.html - message(STATUS "Android SDK Build Tools: Gradle 3.0.0+ builds support is available") - ocv_update(ANDROID_PROJECTS_SUPPORT_GRADLE ON) + if(ANDROID_SDK_TOOLS_VERSION VERSION_LESS 14) + message(FATAL_ERROR "Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.\n" + "${__msg_BUILD_ANDROID_PROJECTS}") endif() - else() - include(${CMAKE_CURRENT_LIST_DIR}/../OpenCVDetectApacheAnt.cmake) - if(ANT_EXECUTABLE AND NOT ANT_VERSION VERSION_LESS 1.7) - message(STATUS "Android SDK Tools: Ant (Eclipse) builds are supported") - ocv_update(ANDROID_PROJECTS_SUPPORT_ANT ON) + + if(NOT ANDROID_SDK_TOOLS_VERSION VERSION_LESS 25.3.0) + message(STATUS "Android SDK Tools: Ant (Eclipse) builds are NOT supported by Android SDK") + ocv_update(ANDROID_PROJECTS_SUPPORT_ANT OFF) + else() + include(${CMAKE_CURRENT_LIST_DIR}/../OpenCVDetectApacheAnt.cmake) + if(ANT_EXECUTABLE AND NOT ANT_VERSION VERSION_LESS 1.7) + message(STATUS "Android SDK Tools: Ant (Eclipse) builds are supported") + ocv_update(ANDROID_PROJECTS_SUPPORT_ANT ON) + endif() endif() endif()