opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Solution for Building OpenCV on Termux by Disabling Android SDK and Java Support in CMake

Open ab2-g opened this issue 1 year ago • 4 comments

Expected behaviour

Write here how did you expect the library to function.

Actual behaviour

Write here what went wrong.

Steps to reproduce

  • example code
  • operating system
  • architecture (e.g. x86)
  • opencv-python version
Issue submission checklist
  • [ ] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • [ ] I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • [ ] The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • [ ] I'm using the latest version of opencv-python

ab2-g avatar Dec 17 '24 10:12 ab2-g

Problem:

When trying to build OpenCV on Termux, the installation fails because CMake looks for Android SDK and Java tools, which are not available in Termux by default.

Solution:

To solve this issue, you can disable Android and Java support in CMake by using the following settings:

cmake -DANDROID=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_JAVA=OFF -DBUILD_FAT_JAVA_LIB=OFF -DWITH_OPENCL=OFF -DWITH_CUDA=OFF ..

This will allow OpenCV to be installed successfully in Termux without any issues related to missing Android SDK or Java.

Additional Details:

  • Operating System: Android (via Termux)
  • Architecture: ARM, x86, etc.
  • OpenCV Version: [mention the version you tested]

ab2-g avatar Dec 17 '24 10:12 ab2-g

Problem:

When trying to build OpenCV on Termux, the installation fails because CMake looks for Android SDK and Java tools, which are not available in Termux by default.

Solution:

To solve this issue, you can disable Android and Java support in CMake by using the following settings:

cmake -DANDROID=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_JAVA=OFF -DBUILD_FAT_JAVA_LIB=OFF -DWITH_OPENCL=OFF -DWITH_CUDA=OFF ..

This will allow OpenCV to be installed successfully in Termux without any issues related to missing Android SDK or Java.

Additional Details:

  • Operating System: Android (via Termux)
  • Architecture: ARM, x86, etc.
  • OpenCV Version: [mention the version you tested]

ab2-g avatar Dec 17 '24 10:12 ab2-g

I am working on the same compilation goal as you, from unbintu to aarch64 Linux Android. Are you compiling the source code from OpenCV or OpenCV Python? Can I see your complete cmake command and process? If I want to call OpenCV's library with Python 3 in termux, how do I configure it in the cmake command?

oldcoder-pixel avatar Jul 20 '25 09:07 oldcoder-pixel

I am working on the same compilation goal as you, from unbintu to aarch64 Linux Android. Are you compiling the source code from OpenCV or OpenCV Python? Can I see your complete cmake command and process? If I want to call OpenCV's library with Python 3 in termux, how do I configure it in the cmake command?

Just write: export CMAKE_ARGS="-DANDROID=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_JAVA=OFF -DBUILD_FAT_JAVA_LIB=OFF -DWITH_OPENCL=OFF -DWITH_CUDA=OFF"

Then you'll be able to build opencv via cmake.

miha1llumi avatar Jul 22 '25 19:07 miha1llumi