-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android compilation fails with opencv #1144
Comments
Have you tried |
I have tried buildozer android clean and deleting the android-sdk folder with no luck. Not sure why it would have to redownload anyways. I downloaded buildozer for the first time last week. I manage to push a working apk to my device that works fine unless it has the opencv dependency. Adding opencv to the venv, main.py and the list of requirements gives the above error. I have tried it on my friends computer with a complete Virtual Machine and not only WSL and get the same error. We are looking into avoiding the crash by installing Android SDK Tools (deprecated since 2017: https://developer.android.com/studio/releases/sdk-tools), manually by using the sdkmanager at .buildozer/android/platform/android-sdk/tools/bin however this doesn't work either. Some help or other ideas would be appreciated. Basically I'm trying to find whether this issue is due to buildozer, a deprecated p4a recipe or opencv themselves. Are you able to reproduce the error? |
We managed to get it to compile with some hacking. Basically opencv(either p4a or the organization) is not compatible with the latest android sdk tools file system. Since setting the android.sdk in buildozer.spec is ignored(# WARNING: Config token app android.sdk is deprecated and ignored, but you set value 15 #android.sdk = 20), we had to rename the cmdline-tools folder(.buildozer/android/platform/android-sdk/tools) use the sdkmanager in it to manually install the deprecated "tools" and delete the cmdline-tools folder. Afterwards we used the sdkmanager in the new deprecated tools folder to reinstall buildtools, platform-tools and platform. This is probably due to some hardcoded paths in opencv's compilation for android. Maybe change the buildozer.spec file to enable an sdk-installation with the old tools instead of cmdline-tools? |
Also maybe the timing needs a slight improvement, my compilation took a bit over 35mins and in the end it printed: |
I use the latest SDK and have built apps with opencv multiple times successfully, and not only me. Also, the SDK is not deprecated, just the way it is packaged changed — now it is available with other stuff as a bundle called commandlinetools. And about what I meant by redownloading, it sometimes happens that something for whatever reason ends up broken. That's why every time building fails, and you can't figure it out, it's worth cleaning the problematic platform environment (built packages etc.), or even a whole building environment (SDK etc.). What about the 'timing', I believe it doesn't count even checking your tool set or doing tests, for example, not even talking about downloading something. The first build always takes a long time to set everything up, then it is usually no more than 30 seconds, and that's on VM. |
Yes that definitely feels like an upstream issue to me as they don't seem to support command line tools yet https://github.com/opencv/opencv/blob/4.3.0/cmake/android/OpenCVDetectAndroidSDK.cmake#L176 |
Dear Osklar, thanks for the recommended solution. I'm very new to kivy, and having the same issue. I tried your solution, but I still receive the same error "Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer".I'm most probably skipping some steps.. Would you please open a little bit your steps, including the commands and versions for reinstalling buildtools, platform-tools and platform? Thanks a lot in advance |
Sure cihangoksu, so basically there is a program that comes with installing buildozer found here "~/.buildozer/android/platform/android-sdk/tools/bin" (or wherever you have buildozer installed) called sdkmanager. With this program you can change the versions of android sdk, tools and platforms, etc. The error: "Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer." hints that we need Android SDK Tools, which has been replaced with something called cmdline-tools recently. You can install Android SDK Tools using the sdkmanager as so: ./sdkmanager --install "tools" as you can find in the list when writing: ./sdkmanager --list --include_obsolete Running the installation may require that you first create a file called /root/.android/repositories.cfg. The issue is that all these programs inside " ~/.buildozer/android/platform/android-sdk/tools/bin$ sudo ./sdkmanager --list --include_obsolete
Installed Obsolete Packages:
After this buildozer android debug should work fine :) |
You rock!! Thank you very much, for a very detailed description all clear now... I followed your steps and app opens now without any error. However, whenever I press a button to activate the camera, the app crashes and turns back to the phone's main screen. Do you think this is also opencv-relevant? (Btw I gave CAMERA permissions both in spec file and in my phone) |
@osklars this is a bug tracker, not a help forum. |
Hello, Below you'll find a quick fix for the version issue. It works on As it's been described below the issue comes from openCV build (cmake) who's using a deprecated sdk tools named
Now it should work as it will be using the old tools dependency. I've succeed to use opencv on my phone, OnePlus 6T. I hope it helps |
Hello, I tried iElsha's comment. When I typed: It said: But then nothing changed. No tools folder was installed. What have I done wrong? |
Can u able to access the camera through opencv? |
are you sure it is right to install these in the root buildozer, or just the buildozer at the app's working directory |
I'm facing this problem and none of the solutions proposed have worked for me. Please help! I just keep getting the same error:
|
Hi, I'm facing the same problem, too. I want to solve it by using sdkmanager, but I can't find sdkmanager in the folder of buildozer. |
same issue , none of the above work around solved @osklars is it possible for you to share image of the linux box with open cv build , i tried many ways but it didnt work |
Hi Gabriel,
I still see some build failure on your latest commit , also can you please
make a readme to make the workflow identical to you.
Regards,
…On Wed, Aug 19, 2020 at 4:41 AM Gabriel Pettier ***@***.***> wrote:
https://github.com/tshirtman/test_p4a_opencv/actions
i created a test project to build from scratch in github action, so anyone
can see what it does, and it builds fine, the commands to get there from a
clean ubuntu can be found at
https://github.com/tshirtman/test_p4a_opencv/blob/master/.github/workflows/buildozer.yml#L19-L30
which are incidentally taken almost straight from the buildozer
documentation.
the apk is uploaded in the artifact of the build, if someone wants to test
it, it does't do anything aside importing cv2 and displaying the version
in a Label.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQHKUV5L3G2PIO4GHRPKGFDSBMDCZANCNFSM4NYHODGA>
.
|
@AndreMiras do you see any quick work around for this issue |
I am still facing the issue. |
So the solutions proposed above are all from native unix or vm right? or can i do same with a docker image? |
They didn't work for me you can try
…On Wed, Aug 26, 2020, 20:45 herbyboi ***@***.***> wrote:
So the solutions proposed above are all from native unix or vm right? or
can i do same with a docker image?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQHKUVYTMFIEX5HK7W4DUMLSCURJFANCNFSM4NYHODGA>
.
|
@osklars , I've tried following your above method, but I'm unable to get it to work. As I've never used android SDK or tools before, I'm not familiar with installation procedures and such. Could you please guide me through the steps? |
If it can help someone, I made a Dockerfile to use as workaround. Here it is : https://github.com/tom333/mycamerai/blob/master/Dockerfile Build it and launch it with podman |
Apologies to bother you, is it possible you can make a small video or image instruction on the work around. I am new to the android conversion process and i have written a kivy app the uses OpenCV but have been stuck with this exact same problem for quiet a longtime now. I will greatly appreciate it. |
Any possibility you can make a image based or short video instruction on how one can achieve this?I have been seating on this issue for long. |
Is there any real resolution to this ? I'm staring at the same problem. |
There is definitely a real solution to this, or a hack to say. i got it right using @iElsha method below. I simply modified it as follow:
|
Hi @franslott, I keep getting the same error even after following the steps. Please see below traceback.
|
This is exactly the same errror i was getting, but those steps above solved it for me. Perhaps you should first delete the /.buildozer folder in the home folder and try again, and after it fails with that error, then you continue with the steps i listed above. |
@franslott you can ignore the last post from me as I ran |
Awesome. |
@codinghedgehog-python - I am not able to delete .buildozer folder. Can you please let me know the command to delete the entire .buildozer directory? Error: |
@GauravSaini728 If you're on Linux just run |
I added `sudo` because it's very often needed with "dot-directories" (hidden directories).
Sent with [ProtonMail](https://protonmail.com) Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
…On Tuesday, 3 November 2020 22:18, Gabriel Pettier ***@***.***> wrote:
(edited: no need for sudo, don't do sudo needlessly, especially with rm, added the ~/ so it works from anywhere)
—
You are receiving this because you were mentioned.
Reply to this email directly, [view it on GitHub](#1144 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AQKPB24YJPZ2OJBPS4QM3OTSOB6RRANCNFSM4NYHODGA).
|
@codinghedgehog-python I have changed the name of buildozer directory and again build the buildozer folder. I did not face the same issue again but get stuck in another issue. I am building a kivi app to capture the video from camera and apply the classification on the video feed. While building the apk file i am encountering very strange error related to functools library. Attaching the screenshot of the error and gdrive link of the entire error. Error Stack: https://drive.google.com/file/d/1faPS9q3q8BY7RXZ2-rj_9HHb8XQgVybF/view?usp=sharing It would be great if anyone could help me to fix this error. |
@CodinjaoftheWorld Can you confirm that you're using pip for Python 3.x and not for 2.7 ? |
@codinghedgehog-python |
Any updates on this? i've tried avery solution, but still get the same error |
You've got Regarding to the error output you're getting. |
Can you please share your email address? I can share the relevant code blocks with you. |
Hi I have been struggling with getting opencv and buildozer working for a few days now. Is there a difference in the android sdk part or buildozer over the few month till now that may make the solutions posted here different? Please anybody help me get opencv and buildozer compile -- Update variable ANDROID_SDK from environment: /home/i/.buildozer/android/platform/android-sdk Use BUILD_ANDROID_PROJECTS=OFF to prepare Android project files without |
Please can anyone help with the issue. Exact same problem trying it out for 4days. |
@abhishekju06 Follow the steps shared by @franslott :
Don't forget to replace I know how frustrating it can be to get OpenCV to work on Android using Python. Follow the steps and it's gonna work. |
Hi, Note:After unzipping the commandlinetools-linux-6858069_latest.zip there is a folder named cmdline-tools |
@abhishekju06 Can you please confirm that you ran |
I ran it just now What are the next step that I should follow to run sdkmanager? |
@abhishekju06 Make sure you're running those commands from |
abhishek@abhishek:~/.buildozer/android/platform/android-sdk$ ls there is no folder named tools when I unzip |
@abhishekju06 I suggest you to reach out to Kivy devs on Discord. They're often very keen to help out https://discord.com/channels/423249981340778496/712344698559397895 |
this
This is definitely a real solution to this. @iElsha you rocks... & @franslott you really made the steps easy to follow. One thing I want to add is just run android debug clean before rebuilding the apk. |
@iruriksl @iElsha @franslott Can you please tell me which version of Opencv would work? Mine is opencv: 4.0.1 and "platforms;android-28" I used the method you people described for opencv issue but when I am running my program cv2.face.LBPHFaceRecognizer_create() is giving me Attribute error cv2.face . I did this tracing via logcat. Can you please help me?? |
If you download the files from android studio's sdk manager and point the directory in the buildozer.spec, then the compilation also works.
Now run:
And the compilation should be successful this time. |
I followed the steps and got tools folder and deleted the .buildozer folder and tried to make apk , but I am getting this below error .
=======================ERROR==================================================== |
Versions
Description
Since I got compilation errors trying to compile my large kivy app with many dependencies to android, I created a minimal example that uses numpy and opencv. This very simple app also fails to compile at the same point:
It seems like the opencv recipe is dependent on SDK Tools (revision 14 or higher), which is deprecated since 2017 when it was replaced by SDK command-line tools.
My minimal example looks like this:
buildozer.spec
Command:
Spec file:
Logs
The text was updated successfully, but these errors were encountered: