Make it possible to build with Android NDK r16#10288
Make it possible to build with Android NDK r16#10288erikman wants to merge 4 commits intoopencv:masterfrom
Conversation
Newer versions of Android ndk have deprecated the "android" executable for creating and updating projects. This patch allows cmake to use "avdmanager" instead for detecting SDK's and if found will not use "android" executable for creating projects. Without a working android executable apks will not be built but we will get lib files for linking with. Older toolchain versions (using gcc-4.8) will produce binaries for x86 and x86_64 that don't link with newer toolchain versions (using gcc-4.9), hence the need for building those binaries with a newer version of the toolchain.
Before ANDROID_SDK had to be specified as an environment variable.
This makes it possible to compile OpenCV with for instance ndk-r16
|
Consider using Android CMake toolchain file instead (it shipped with NDK 15+, so it is supported natively and should be well tested): Options are similar, but not exact. Something like this:
Lets leave OpenCV's Android toolchain "as is" for legacy NDKs (and old devices). |
|
Thanks @alalek, that sounds like a good idea, I'll have a look |
|
In my personal Android point of view I want to see it merged ! With this spirit "let things untouched although a improvement/modernization is there" let OpenCV midterm (current) unusable. Look at current Android situation, it's not usable out of the box:
|
|
@hannesa2 We can't merge any incoming patches, because who would maintain this a few months later? The first two commits just hides "android" tool problem, without resolving them (creates .apk files with zero size, including Android tests - do we really need this?). Only complete migration to gradle builds can help here (see #8460). Also ANDROID_SDK variable is not in recommended set of environment variables: https://developer.android.com/studio/command-line/variables.html The third 90cc3f6 commit is useful, but it is not complete: CMake is not able to properly call "find_file()" on headers. I'm not able to reproduce problem resolved by 3135af8 commit. It should not break anything, but I have no idea that problem related to NDK16 is resolved here. @erikman Is it a build problem or runtime issue (.apk crash on launch)? |
|
@alalek The problem is a build problem, I ran into this when I needed to recompile due to #10229 so my only goal was to be able to build libraries with r16 with my own build flags. I did not need the I was not aware of 3135af8 and 90cc3f6 are not needed when using With the two first patches I'm able to build with the toolchain from ndk. Still doing some final testing. |
|
I looked into Locally I get around this by passing it from my my point is that I would like to pass the path as a cmake variable and not just an environment variable (which is harder to pass into cmake from gradle). So what I was doing in my patch was only to expose the Now I'm a bit hesitant to rename it since it is used by many of the support scripts: |
This pull request makes it possible to build OpenCV with Android NDK r16. Android have switched to unified include directories, and deprecated the
androidexecutable.This patch makes it possible to compile the native libraries. On NDK r16 the
androidexecutable is not able to createbuild.xmlfiles for use withantso it will not build any.apkfiles.