Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: don't require deprecated tools #21736

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions cmake/android/OpenCVDetectAndroidSDK.cmake
Expand Up @@ -56,8 +56,13 @@ endmacro()
macro(ocv_detect_android_sdk_tools)
# https://developer.android.com/studio/releases/sdk-tools.html
if(NOT DEFINED ANDROID_SDK_TOOLS)
if(DEFINED ANDROID_SDK AND EXISTS "${ANDROID_SDK}/tools")
set(ANDROID_SDK_TOOLS "${ANDROID_SDK}/tools" CACHE INTERNAL "Android SDK Tools path")
if(DEFINED ANDROID_SDK)
if (EXISTS "${ANDROID_SDK}/cmdline-tools")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not the same and can't be exchanged. Just compare:

cmdline-tools/latest/source.properties:

Pkg.Revision=7.0
Pkg.Path=cmdline-tools;7.0
Pkg.Desc=Android SDK Command-line Tools

vs

tools/source.properties

Pkg.UserSrc=false
Pkg.Revision=26.1.1
Platform.MinPlatformToolsRev=20
Pkg.Dependencies=emulator
Pkg.Path=tools
Pkg.Desc=Android SDK Tools

OpenCV doesn't use "tools" with modern "gradle" flow actually. They are use with legacy "ant" build flow.


Try to comment out #ocv_detect_android_sdk_tools() call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced to a simple check that tools found.

cmdline-tools tools changed their versioning so the latest one is 9.0. More about my build steps here: #23642

set(ANDROID_SDK_TOOLS "${ANDROID_SDK}/cmdline-tools" CACHE INTERNAL "Android SDK Tools path")
set(ANDROID_SDK_CMDLINE_TOOLS "${ANDROID_SDK_TOOLS}" CACHE INTERNAL "Android SDK Command-line Tools path")
elseif(EXISTS "${ANDROID_SDK}/tools")
set(ANDROID_SDK_TOOLS "${ANDROID_SDK}/tools" CACHE INTERNAL "Android SDK Tools path")
endif()
endif()
endif()
if(NOT DEFINED ANDROID_SDK_TOOLS)
Expand Down Expand Up @@ -173,12 +178,12 @@ if(BUILD_ANDROID_PROJECTS)
ocv_detect_android_sdk_tools()
ocv_detect_android_sdk_build_tools()

if(ANDROID_SDK_TOOLS_VERSION VERSION_LESS 14)
if(NOT DEFINED ANDROID_SDK_CMDLINE_TOOLS AND 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_TOOLS_VERSION VERSION_LESS 25.3.0)
if(DEFINED ANDROID_SDK_CMDLINE_TOOLS OR 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)
Expand Down