Skip to content

Building OpenCV for Android using Android cmdline-tools #21735

@anders-nylander

Description

@anders-nylander

Android cmdline-tools no longer installs the deprecated Android SDK Tools package. This causes a cmake configure error when OpenCV tries to find these tools in ${ANDROID_SDK}/tools if they're not already installed.

System information (version)
  • OpenCV => ❔
  • Operating System / Platform => ❔
  • Compiler => ❔
Detailed description
Steps to reproduce
  1. Clean install Android SDK using the latest cmdline-tools package.
  2. Build OpenCV for Android using the included python helper script, e.g. python3 /opencv/platforms/android/build_sdk.py --sdk_path=/opt/android-sdk --no_samples_build --config=/opencv/platforms/android/ndk-22.config.py
    Build fails during configure step with a message like this one:
-- Update variable ANDROID_SDK_ROOT from environment: /opt/android-sdk
-- Update variable ANDROID_HOME from environment: /opt/android-sdk
-- Update variable ANDROID_SDK from environment: /opt/android-sdk
CMake Error at cmake/android/OpenCVDetectAndroidSDK.cmake:64 (message):
  Android SDK Tools: can't automatically find Android SDK Tools.  Specify
  path via ANDROID_SDK_TOOLS variable
Call Stack (most recent call first):
  cmake/android/OpenCVDetectAndroidSDK.cmake:173 (ocv_detect_android_sdk_tools)
  CMakeLists.txt:746 (include)


-- Configuring incomplete, errors occurred!
See also "/build/o4a/CMakeFiles/CMakeOutput.log".
See also "/build/o4a/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "/opencv/platforms/android/build_sdk.py", line 445, in <module>
    builder.build_library(abi, do_install)
  File "/opencv/platforms/android/build_sdk.py", line 262, in build_library
    execute(cmd)
  File "/opencv/platforms/android/build_sdk.py", line 30, in execute
    raise Fail("Child returned: %s" % retcode)
__main__.Fail: Child returned: 1
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions