Repository navigation
Closed
Labels
category: build/installfeaturefutureThis issue can't be fixed during restrictions of the compatibility requirementsplatform: android
Description
System information (version)
- OpenCV => 3.2.0
- Operating System / Platform => Gentoo / Android
- Compiler => Android NDK toolchain gcc
Detailed description
OpenCVDetectAndroidSDK.cmake doesn't detect an Android SDK after updating to the SDK Tools, Revision 25.3.0.
-- SDK target: android_sdk_target_status-NOTFOUND
-- android tool: NO~/Android/Sdk/tools/android
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanagerAn older version of the tools just werks.
SDK Tools, Revision 25.3.0 (March 2017)
...
Obsolete/deprecated tools have been removed:
android
ddms (instead see Using DDMS)
draw9patch (instead see Draw 9-patch)
hierarchyviewer (instead see Profile Your Layout with Hierarchy Viewer)
traceview (instead see Profiling with Traceview and dmtracedump)
ant scripts
Project and activity templates
Steps to reproduce
- Update SDK tools using an Android Studio
- Try to build an OpenCV for Android with Java wrappers and examples support.
alalek:
Current solution is to downgrade SDK Tools to the latest available version prior 25.3.0: 25.2.5. Direct download links are:
- https://dl.google.com/android/repository/tools_r25.2.5-linux.zip (265Mb)
- https://dl.google.com/android/repository/tools_r25.2.5-macosx.zip (191Mb)
- https://dl.google.com/android/repository/tools_r25.2.5-windows.zip (293Mb)
Reacted by Aaron Simmons, hpsaturn, Aleksandr Medvedev, Jioin, Zhyon, Laurent Berger and pminimd
Reacted by Ben John
Reacted by Ben John
Metadata
Metadata
Assignees
Labels
category: build/installfeaturefutureThis issue can't be fixed during restrictions of the compatibility requirementsplatform: android
Activity
diroitman commentedon Apr 5, 2017
Hi
I'm also interested - so how do you build opencv for android platform?
I tried platform/android/build_sdk.py script and it gives me the same error
Thank you
mishurov commentedon Apr 5, 2017
Gentoo has the old versions of the SDK with the working "android" tool. I set an environment variable with the path to the old version instead of the user directory where Android Studio installs recent versions of the SDK.
https://packages.gentoo.org/packages/dev-util/android-sdk-update-manager
adamajohnston commentedon Jul 8, 2017
To clarify in case it isn't obvious, the workaround is not to switch to Gentoo or try to build the 24.4.1 ebuild packge but to download the (unlisted) Android SDK tools directly from Google here...
https://dl.google.com/android/repository/tools_r24.4.1-linux.zip
https://dl.google.com/android/repository/tools_r24.4.1-macosx.zip
https://dl.google.com/android/repository/tools_r24.4.1-windows.zip
peterchaula commentedon Aug 11, 2017
I solved this by using ndk-r9 and tools at links provided by @adamajohnston but ran into other problems with 64 bit ABIs
mishurov commentedon Aug 16, 2017
@victorv, it's a workaround and half-measures, not a solution.
peterchaula commentedon Aug 16, 2017
@victorv an older version of CMake is also required for that to build correctly
hoonkai commentedon Jan 1, 2018
Is there any plan to have this issue looked at? Tools is already r27 now.
peterchaula commentedon Apr 11, 2018
@NGriffiths you need to strip out intel threading libs (TBB). That'll shave off ~15MB off your library.
alalek commentedon Apr 11, 2018
I observed significant size increase of OpenCV4Android package during preparation of #10515:
This is result of switching from NDK r10e -> 16b.
WargnierP commentedon May 9, 2018
Unfortunately, this fix does not seem to do the trick for me: I can compile but the sdk/java folder and its content does not get created, making my build useless since it is required to import OpenCV in the projet. This seems to be linked to building the Android projects, which I had to disable for the configuration to go through. After many trials and errors to resolve all the configure errors CMake gave me, I ended up being stuck with
CMake Error at cmake/android/android_ant_projects.cmake:40 (message): Android: List of installed Android targets is empty Call Stack (most recent call first): cmake/android/OpenCVDetectAndroidSDK.cmake:202 (include) CMakeLists.txt:649 (include)I am on a windows 10 system with OpenCV 3.4.1, Android studio 3.1.2, CMake 3.11.0, NDK r16, Android build tools 27.0.3 and 25.0.3 and I downloaded the Android tools 25.2.3 as indicated here, which I explicitely told CMake to use by creating the "ANDROID_SDK_TOOLS" variable manually. However, ANDROID_SDK variable points to my Android Studio SDK install, which is version the latest version.
I have to mention that I also had to add the following variables manually, with the following configurations:
I also tried selecting ANDROID_SDK_BUILD_TOOLS_VERSION between 27.0.3 and 25.0.3. But that did not change a thing. Lastly, I have to mention that, so far, I have only tried compiling for armeabi_v7a.
Does anyone know what can cause the issue I'm having and how to fix it?
Also, I noticed that CMake created the "ANDROID_SDK_TARGET" variable, but I don't know what value I should give it. Should I have to specify it manually, because I read nothing about that anywhere? What value should I give it?
Could the issue be caused by a mismatch between the tools and build-tools version? If so, what is the build-tools version compatible with the 25.2.3 tools version?
Any help is appreciated. Thanks in advance.
alalek commentedon May 9, 2018
@WargnierP What Android platforms did you installed?
WargnierP commentedon May 14, 2018
Hi @alalek , I have installed Android Platforms 24, 25 and 27. Should I install other versions ?
robertwgh commentedon Jun 9, 2018
@NGriffiths thanks for the info.
ANDROID_STL="libc++_shared"should beANDROID_STL="c++_shared"xindongzhang commentedon Sep 4, 2018
I solve this problem by enable building java and android examples, following is my scripts:
actually, you only need to set -DBUILD_JAVA=OFF -DBUILD_ANDROID_EXAMPLES=OFF
StainlessStlRat commentedon Oct 6, 2018
So many people are successfully building the lib for c++_static/shared. Why on EARTH hasn't there been an SDK4Android commit with the new binaries?
alalek commentedon Oct 6, 2018
Additional info about
c++_static/sharedlimitations: https://developer.android.com/ndk/guides/cpp-supportGCC (and its libs) has beed removed from Android NDK r18: https://developer.android.com/ndk/downloads/revision_history
Current OpenCV builds use outdated Android NDK 10e and based on Eclipse Ant build.xml projects (it was actual for first OpenCV 3.0 release).
Need to update Android build deps before next major OpenCV release.
hannesa2 commentedon Oct 7, 2018
An other important hint here is:
crazyhappygame commentedon Oct 9, 2018
@alalek are there any ticket for:
mishurov commentedon Oct 9, 2018
Why don't you contact with googlers/jetbrainers and make that done in the case the problem is on their side. I don't like either that they push a lot into the Studio and make it harder for vim, react, etc.
Howave commentedon Oct 30, 2018
you can modify your ${ANDROID_NDK}/build/cmake/android.toolchain.cmake,remove "-g" debug flag, then the static libs size will be reduced
Howave commentedon Oct 30, 2018
my build cmd is as below(ndk-r17c):
cmake -GNinja -DINSTALL_ANDROID_EXAMPLES=OFF -DANDROID_EXAMPLES_WITH_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DWITH_OPENCL=OFF -DWITH_TBB=ON -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DANDROID_TOOLCHAIN=clang -DANDROID_STL=c++_static -DANDROID_SDK_TARGET=19 -DBUILD_ANDROID_PROJECTS=ON -DANDROID_ABI=armeabi-v7a -DANDROID_ARM_NEON=ON -DANDROID_PROJECTS_BUILD_TYPE=ANT ..
ninja -j8
ninjia install
StainlessStlRat commentedon Oct 30, 2018
Has anyone been able to get it to work with a lower SDK flag? Say sdk level 15?
wernerd commentedon Nov 4, 2018
@Howave Which SDK did you use to build opencv with r17c? The old 25 setup with the 'android' command line tool or the new one - 26.1.1?
Actually 26.1.1 has an 'android' command line tool which simulates a small part of the 'android sdk' functions: list and update, but not create. IMHO OpenCV does not really need the 'android' command, only to support the Eclipse Android setup for the SDK part? Or do I miss something here?
Howave commentedon Nov 4, 2018
sdk-platform 28.0.1 with sdk-tool 26.1.1,
then I remove the sdk-tool 26.1.1 and replace with 25
alalek commentedon Dec 7, 2018
There is initial migration on gradle builds: #13386
Review and suggestions are welcome!
Add build tools 25.2.5 option for OpenCV builds