Ask Your Question
0

How do I properly build Android OpenCV from sources?

asked 2018-08-11 16:52:48 -0600

wmmc88 gravatar image

The end goal is to build opencv with contrib for Android, but i cant seem to get the build_sdk.py script to even work without the --extra_pack flag

I've downloaded build Tools 25.0.3, sdk tools 25.2.5,, ndk 16b and the latest opencv and contrib repos.

Commands:

export ANDROID_SDK=/home/wmmc88/Android/Sdk/

export ANDROID_NDK=/home/wmmc88/Android/android-ndk-r16b/

python3 ../android/build_sdk.py test/ ../../../opencv --no_ccache --config ../android/ndk-16.config.py

Output:

> Args: Namespace(build_doc=False,
> config='../android/ndk-16.config.py',
> extra_modules_path=None,
> extra_pack=None, force_copy=False,
> force_opencv_toolchain=False,
> ndk_path=None, no_ccache=True,
> opencv_dir='../../../opencv',
> sdk_path=None, sign_with=None,
> work_dir='test/') Package
> configuration:
> ================================================================================ ABIs = [
>     ABI("2", "armeabi-v7a", "arm-linux-androideabi-4.9",
> cmake_vars=dict(ANDROID_ABI='armeabi-v7a
> with NEON')),
>     ABI("1", "armeabi",     "arm-linux-androideabi-4.9",
> cmake_vars=dict(WITH_TBB='OFF')),
>     ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
>     ABI("5", "x86_64",      "x86_64-4.9"),
>     ABI("4", "x86",         "x86-4.9"), ]
> ================================================================================ Android NDK path:
> /home/wmmc88/Android/android-ndk-r16b/
> Android SDK path:
> /home/wmmc88/Android/Sdk/ Check dir
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test
> (create: True, clean: False) Check dir
> /home/wmmc88/OpenCVRepo/opencv
> (create: False, clean: False) Check
> dir
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/o4a
> (create: True, clean: True) Removing
> file:
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/o4a/CMakeCache.txt
> Removing dir:
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/o4a/CMakeFiles
> Removing dir:
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/o4a/3rdparty
> Removing file:
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/o4a/CMakeDownloadLog.txt
> Removing dir:
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/o4a/junk
> Check dir
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/OpenCV-android-sdk
> (create: True, clean: True) Removing
> dir:
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/OpenCV-android-sdk/sdk
> Check dir
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/OpenCV-android-sdk/sdk/java/javadoc
> (create: True, clean: True) Detected
> OpenCV version: 4.0.0-pre Detected
> Engine version: 3.42 Check dir
> /home/wmmc88/OpenCVRepo/opencv/platforms/Custom/test/build_service_armeabi-v7a
> (create: True, clean: True)
> =====
> ===== Building library for armeabi-v7a (arm-linux-androideabi-4.9)
> =====
> 
> Executing: ['cmake', '-GNinja',
> '-DBUILD_TESTS=ON',
> '-DINSTALL_TESTS=ON',
> "-DCMAKE_TOOLCHAIN_FILE='/home/wmmc88/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake'",
> "-DWITH_OPENCL='OFF'",
> "-DWITH_IPP='OFF'", "-DWITH_TBB='ON'",
> "-DBUILD_EXAMPLES='OFF'",
> "-DBUILD_TESTS='OFF'",
> "-DBUILD_PERF_TESTS='OFF'",
> "-DBUILD_DOCS='OFF'",
> "-DBUILD_ANDROID_EXAMPLES='ON'",
> "-DINSTALL_ANDROID_EXAMPLES='ON'",
> "-DANDROID_STL='gnustl_static'",
> "-DANDROID_ABI='armeabi-v7a with
> NEON'",
> "-DANDROID_TOOLCHAIN_NAME='arm-linux-androideabi-4.9'",
> "-DANDROID_PLATFORM_ID='2'",
> '/home/wmmc88/OpenCVRepo/opencv']
> Executing: cmake -GNinja
> -DBUILD_TESTS=ON -DINSTALL_TESTS=ON -DCMAKE_TOOLCHAIN_FILE='/home/wmmc88/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake'
> -DWITH_OPENCL='OFF' -DWITH_IPP='OFF' -DWITH_TBB='ON' -DBUILD_EXAMPLES='OFF' -DBUILD_TESTS='OFF' -DBUILD_PERF_TESTS='OFF' -DBUILD_DOCS='OFF' -DBUILD_ANDROID_EXAMPLES='ON' -DINSTALL_ANDROID_EXAMPLES='ON' -DANDROID_STL='gnustl_static' -DANDROID_ABI='armeabi-v7a with NEON' -DANDROID_TOOLCHAIN_NAME='arm-linux-androideabi-4.9'
> -DANDROID_PLATFORM_ID='2' /home/wmmc88 ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-08-15 12:22:41 -0600

wmmc88 gravatar image

updated 2018-08-15 12:39:27 -0600

So after many many hours (days?) of struggling, i managed to get their build script working on my system. This is what I needed to use to get it to build properly:

  • jdk 1.6
  • ant 1.9.6
  • Android SDK Tools 25.2.2
  • Android Build Tools 23.0.3
  • Android NDK r10e
  • Python 2.7
  • latest ninja

I tried my best to mirror the tools used by their automated build system: http://pullrequest.opencv.org/buildbo...

I also found out that their automated nightly builds have a section for android+contrib and they are available here (I have literally no idea how I managed to find this): http://pullrequest.opencv.org/buildbo...

edit flag offensive delete link more

Comments

Good find with those nightly android builds. I feel your pain, I have also been trying to build this for days

broomy gravatar imagebroomy ( 2019-03-29 11:21:59 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-11 16:52:48 -0600

Seen: 3,216 times

Last updated: Aug 15 '18