Open osklars opened 4 years ago
Have you tried buildozer android clean
? buildozer distclean
? Or maybe just delete the SDK tools folder to make it redownload.
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: BUILD SUCCESSFUL in 21s
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 Please take a look at their existing issue and report if there if needed. It's also possible to patch it p4a side until they take action. Pull requests are welcome :smile:
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?
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
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?
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" are the cmdline-tools you are trying to replace with the old sdk tools, include sdkmanager that you are currently running. Therefor to be able to actually reinstall a program using the program itself you need to first rename the folder to something like "~/.buildozer/android/platform/android-sdk/opencv_incompatible_tools" before running ./sdkmanager --install "tools". This will then create a new folder "~/.buildozer/android/platform/android-sdk/tools" with a new sdkmanager which can be used to install some build-tools and platform before compiling. If all done correctly you should be able to do like this to see that all the installed packages can be found by you sdkmanager:
~/.buildozer/android/platform/android-sdk/tools/bin$ sudo ./sdkmanager --list --include_obsolete Warning: File /root/.android/repositories.cfg could not be loaded. Installed packages:=====================] 100% Computing updates... Path | Version | Description | Location |
---|---|---|---|
emulator | 30.0.12 | Android Emulator | emulator/ |
patcher;v4 | 1 | SDK Patch Applier v4 | patcher/v4/ |
platform-tools | 30.0.2 | Android SDK Platform-Tools | platform-tools/ |
platforms;android-27 | 3 | Android SDK Platform 27 | platforms/android-27/ |
Installed Obsolete Packages: Path | Version | Description | Location |
---|---|---|---|
build-tools;29.0.0-rc3 | 29.0.0 rc3 | Android SDK Build-Tools 29-rc3 | build-tools/29.0.0-rc3/ |
tools | 26.1.1 | Android SDK Tools | tools/ |
After this buildozer android debug should work fine :)
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?
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" are the cmdline-tools you are trying to replace with the old sdk tools, include sdkmanager that you are currently running. Therefor to be able to actually reinstall a program using the program itself you need to first rename the folder to something like "~/.buildozer/android/platform/android-sdk/opencv_incompatible_tools" before running ./sdkmanager --install "tools". This will then create a new folder "~/.buildozer/android/platform/android-sdk/tools" with a new sdkmanager which can be used to install some build-tools and platform before compiling. If all done correctly you should be able to do like this to see that all the installed packages can be found by you sdkmanager:
~/.buildozer/android/platform/android-sdk/tools/bin$ sudo ./sdkmanager --list --include_obsolete Warning: File /root/.android/repositories.cfg could not be loaded. Installed packages:=====================] 100% Computing updates...
Path Version Description Location emulator 30.0.12 Android Emulator emulator/ patcher;v4 1 SDK Patch Applier v4 patcher/v4/ platform-tools 30.0.2 Android SDK Platform-Tools platform-tools/ platforms;android-27 3 Android SDK Platform 27 platforms/android-27/ Installed Obsolete Packages:
Path Version Description Location build-tools;29.0.0-rc3 29.0.0 rc3 Android SDK Build-Tools 29-rc3 build-tools/29.0.0-rc3/ tools 26.1.1 Android SDK Tools tools/ 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) Thank you in advance for your help :-)
@osklars this is a bug tracker, not a help forum. Use Discord, Stackoverflow or forum for support
Hello,
Below you'll find a quick fix for the version issue. It works on python 3.6.2
, WSL Ubuntu and buildozer
.
As it's been described below the issue comes from openCV build (cmake) who's using a deprecated sdk tools named tools
. This one has been replaced by cmdlines-tools
.
mkdir ~/.buildozer/android/platform/android-sdk
mv tools old-tools
tools
:
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "tools"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platforms;android-27"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platform-tools"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "patcher;v4"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "emulator"
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: me@ubuntu:~/.buildozer/android/platform/android-sdk/old-tools/bin$ ./sdkmanager --install "tools"
It said:
Warning: Observed package id 'cmdline-tools;2.0' in inconsistent location '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/cmdline-tools/2.0' (Expected '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/2.0')
Warning: Observed package id 'tools' in inconsistent location '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/tools' (Expected '/home/me/.buildozer/android/platform/android-sdk/tools')
Warning: Observed package id 'tools' in inconsistent location '/home/me/.buildozer/android/platform/android-sdk/old-tools' (Expected '/home/me/.buildozer/android/platform/android-sdk/tools')
Warning: Already observed package id 'tools' in '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/tools'. Skipping duplicate at '/home/me/.buildozer/android/platform/android-sdk/old-tools'
Warning: Observed package id 'cmdline-tools;2.0' in inconsistent location '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/cmdline-tools/2.0' (Expected '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/2.0')
Warning: Observed package id 'tools' in inconsistent location '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/tools' (Expected '/home/me/.buildozer/android/platform/android-sdk/tools')
Warning: Observed package id 'tools' in inconsistent location '/home/me/.buildozer/android/platform/android-sdk/old-tools' (Expected '/home/me/.buildozer/android/platform/android-sdk/tools')
Warning: Already observed package id 'tools' in '/home/me/.buildozer/android/platform/android-sdk/cmdline-tools/tools'. Skipping duplicate at '/home/me/.buildozer/android/platform/android-sdk/old-tools'
Warning: File /home/me/.android/repositories.cfg could not be loaded.
[=======================================] 100% Computing updates...
But then nothing changed. No tools folder was installed.
What have I done wrong? Cheers
Hello,
Below you'll find a quick fix for the version issue. It works on
python 3.6.2
, WSL Ubuntu andbuildozer
.As it's been described below the issue comes from openCV build (cmake) who's using a deprecated sdk tools named
tools
. This one has been replaced bycmdlines-tools
.
- Download cmdlines-tools from google
- Create a directory for the android sdk at buildozer android location:
mkdir ~/.buildozer/android/platform/android-sdk
- Move the zip to this folder and unzip it
- Rename the folder
mv tools old-tools
- Install missing dependencies & the famous
tools
:sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "tools"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platforms;android-27"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platform-tools"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "patcher;v4"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "emulator"
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
Can u able to access the camera through opencv?
5. sudo ./sdkmanager --sdk_root=/home/
/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3"
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:
Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.
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. I can't even find the folder of android or platform in buildozer. What's wrong with my installation on buildozer? I have no idea now...
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 notifications@github.com 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 https://github.com/kivy/buildozer/issues/1144#issuecomment-675763626, 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 notifications@github.com 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 https://github.com/kivy/buildozer/issues/1144#issuecomment-680944141, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQHKUVYTMFIEX5HK7W4DUMLSCURJFANCNFSM4NYHODGA .
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" are the cmdline-tools you are trying to replace with the old sdk tools, include sdkmanager that you are currently running. Therefor to be able to actually reinstall a program using the program itself you need to first rename the folder to something like "~/.buildozer/android/platform/android-sdk/opencv_incompatible_tools" before running ./sdkmanager --install "tools". This will then create a new folder "~/.buildozer/android/platform/android-sdk/tools" with a new sdkmanager which can be used to install some build-tools and platform before compiling. If all done correctly you should be able to do like this to see that all the installed packages can be found by you sdkmanager:
~/.buildozer/android/platform/android-sdk/tools/bin$ sudo ./sdkmanager --list --include_obsolete Warning: File /root/.android/repositories.cfg could not be loaded. Installed packages:=====================] 100% Computing updates...
Path Version Description Location emulator 30.0.12 Android Emulator emulator/ patcher;v4 1 SDK Patch Applier v4 patcher/v4/ platform-tools 30.0.2 Android SDK Platform-Tools platform-tools/ platforms;android-27 3 Android SDK Platform 27 platforms/android-27/ Installed Obsolete Packages:
Path Version Description Location build-tools;29.0.0-rc3 29.0.0 rc3 Android SDK Build-Tools 29-rc3 build-tools/29.0.0-rc3/ tools 26.1.1 Android SDK Tools tools/ After this buildozer android debug should work fine :)
@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
podman run -it --privileged -volume /dev/bus/usb:/dev/bus/usb --volume buildozer_home:/root/.buildozer --volume /home/moi/.android:/root/.android --volume .:/home/user/hostcwd buildozer android debug deploy run logcat
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?
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" are the cmdline-tools you are trying to replace with the old sdk tools, include sdkmanager that you are currently running. Therefor to be able to actually reinstall a program using the program itself you need to first rename the folder to something like "~/.buildozer/android/platform/android-sdk/opencv_incompatible_tools" before running ./sdkmanager --install "tools". This will then create a new folder "~/.buildozer/android/platform/android-sdk/tools" with a new sdkmanager which can be used to install some build-tools and platform before compiling. If all done correctly you should be able to do like this to see that all the installed packages can be found by you sdkmanager:
~/.buildozer/android/platform/android-sdk/tools/bin$ sudo ./sdkmanager --list --include_obsolete Warning: File /root/.android/repositories.cfg could not be loaded. Installed packages:=====================] 100% Computing updates... Path Version Description Location emulator 30.0.12 Android Emulator emulator/ patcher;v4 1 SDK Patch Applier v4 patcher/v4/ platform-tools 30.0.2 Android SDK Platform-Tools platform-tools/ platforms;android-27 3 Android SDK Platform 27 platforms/android-27/
Installed Obsolete Packages: Path Version Description Location build-tools;29.0.0-rc3 29.0.0 rc3 Android SDK Build-Tools 29-rc3 build-tools/29.0.0-rc3/ tools 26.1.1 Android SDK Tools tools/
After this buildozer android debug should work fine :)
@BlackXDragon
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.
Hello,
Below you'll find a quick fix for the version issue. It works on
python 3.6.2
, WSL Ubuntu andbuildozer
.As it's been described below the issue comes from openCV build (cmake) who's using a deprecated sdk tools named
tools
. This one has been replaced bycmdlines-tools
.1. Download [cmdlines-tools from google](https://developer.android.com/studio#cmdline-tools) 2. Create a directory for the android sdk at buildozer android location: `mkdir ~/.buildozer/android/platform/android-sdk` 3. Move the zip to this folder and unzip it 4. Rename the folder `mv tools old-tools` 5. Install missing dependencies & the famous `tools`: `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "tools"` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3"` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platforms;android-27"` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platform-tools" ` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "patcher;v4" ` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "emulator"`
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
@iElsha
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.
@codinghedgehog-python
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:
After the failed attempt, move to the folder /.buildozer/android/platform/android-sdk `
rename the "tools" folder to something like "opencv_incompatible_tools"
cd into the renamed folder which is now renamed "opencv_incompatible_tools"
cd into "bin" of the the renamed "opencv_incompatible tools" folder such that you are now in renamed "opencv_incompatible_tools/bin", here you will find the "sdkmanager"
Now run number 5 of @iElsha instruction as below, to Install missing dependencies & new tools: Note you will have to add your USERNAME of your operating system to his instruction where it says USERNAME.
After that you will have a new "tools" folder in the /.buildozer/android/platform/android-sdk
Now that we had used the "opencv_incompatible_tools" that we had renamed, delete it. You will only have the new downloaded "tools" folder in your /.buildozer/android/platform/android-sdk
Go back and re-run the "buildozer -v android debug deploy run logcat" command, hope it works.
Hello,
Below you'll find a quick fix for the version issue. It works on
python 3.6.2
, WSL Ubuntu andbuildozer
.As it's been described below the issue comes from openCV build (cmake) who's using a deprecated sdk tools named
tools
. This one has been replaced bycmdlines-tools
.1. Download [cmdlines-tools from google](https://developer.android.com/studio#cmdline-tools) 2. Create a directory for the android sdk at buildozer android location: `mkdir ~/.buildozer/android/platform/android-sdk` 3. Move the zip to this folder and unzip it 4. Rename the folder `mv tools old-tools` 5. Install missing dependencies & the famous `tools`: `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "tools"` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3"` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platforms;android-27"` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platform-tools" ` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "patcher;v4" ` `sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "emulator"`
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
Hi @franslott,
I keep getting the same error even after following the steps. Please see below traceback.
STDOUT:
-- Looking for ccache - not found
-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT
-- libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-4.0.1-libjpeg-turbo
-- Android: fixup -g compiler option from Android toolchain
-- Update variable ANDROID_SDK from environment: /home/mark/.buildozer/android/platform/android-sdk
CMake Error at cmake/android/OpenCVDetectAndroidSDK.cmake:176 (message):
Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.
Use BUILD_ANDROID_PROJECTS=OFF to prepare Android project files without
building them
Call Stack (most recent call first):
CMakeLists.txt:780 (include)
-- Configuring incomplete, errors occurred!
See also "/home/mark/frontend/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/opencv/armeabi-v7a__ndk_target_21/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/home/mark/frontend/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/opencv/armeabi-v7a__ndk_target_21/opencv/build/CMakeFiles/CMakeError.log".
STDERR:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1260, in <module>
main()
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 709, in __init__
getattr(self, command)(args)
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 213, in build_dist_from_args
build_recipes(build_order, python_modules, ctx,
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 577, in build_recipes
recipe.build_arch(arch)
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/recipes/opencv/__init__.py", line 74, in build_arch
shprint(sh.cmake,
File "/home/mark/frontend/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
for line in output:
File "/home/mark/frontend/venv/lib/python3.8/site-packages/sh.py", line 907, in next
self.wait()
File "/home/mark/frontend/venv/lib/python3.8/site-packages/sh.py", line 837, in wait
self.handle_command_exit_code(exit_code)
File "/home/mark/frontend/venv/lib/python3.8/site-packages/sh.py", line 861, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
@codinghedgehog-python
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 buildozer android clean
and then ran the command and it worked.
Thank you.
@codinghedgehog-python
Awesome.
@codinghedgehog-python
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.
@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: rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/stat_sys_warning.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ab_stacked_transparent_light_holo.9.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ic_volume.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/pointer_arrow_large.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ic_menu_selectall_holo_light.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ic_menu_cc_am.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ic_menu_always_landscape_portrait.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ic_menu_delete.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/btn_keyboard_key_dark_normal_on_holo.9.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/list_section_divider_holo_dark.9.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/progressbar_indeterminate_holo2.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/btn_rating_star_off_disabled_holo_dark.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ic_dialog_email.png': Permission denied rm: cannot remove '.buildozer/android/platform/android-sdk/platforms/android-27/data/res/drawable-mdpi/ic_media_route_connecting_dark_12_mtrl.png': Permission denied rm: cannot remove '.buildozer/android/platform/an
@GauravSaini728 If you're on Linux just run sudo rm -rf ~/.buildozer
from your home directory.
I added sudo
because it's very often needed with "dot-directories" (hidden directories).
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Tuesday, 3 November 2020 22:18, Gabriel Pettier notifications@github.com 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, or unsubscribe.
@codinghedgehog-python Thanks for your response. I ran the same commnad and getting the same error of permission denied.
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. I am using opencv and tensorflow libraries for classification and same are maintained in buildozer.spec file.
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 buildozer.spec file: https://drive.google.com/file/d/1W631qFDyUqMdc0hqU9uj-LCI1hfx40YP/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 this is the python version in my venv- Python 3.6.9
Any updates on this? i've tried avery solution, but still get the same error
@codinghedgehog-python Thanks for your response. I ran the same commnad and getting the same error of permission denied.
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. I am using opencv and tensorflow libraries for classification and same are maintained in buildozer.spec file.
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 buildozer.spec file: https://drive.google.com/file/d/1W631qFDyUqMdc0hqU9uj-LCI1hfx40YP/view?usp=sharing
It would be great if anyone could help me to fix this error.
You've got functools
twice on that requirements line in the buildozer.spec
file you provided. Also if you'll be using
opencv's camera you gonna need opencv_extras
recipe alongside opencv
. I did at least.
Regarding to the error output you're getting. TypeError
is almost always about the developer giving it the wrong thing or omitting something altogether. It complains about missing argument from what I've gathered. If you can share the relevant code block.
I suspect you're missing an argument in partial()
method of the functools
module but can't tell for sure without seeing
the code block.
@codinghedgehog-python Thanks for your response. I ran the same commnad and getting the same error of permission denied. 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. I am using opencv and tensorflow libraries for classification and same are maintained in buildozer.spec file. 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 buildozer.spec file: https://drive.google.com/file/d/1W631qFDyUqMdc0hqU9uj-LCI1hfx40YP/view?usp=sharing It would be great if anyone could help me to fix this error.
You've got
functools
twice on that requirements line in thebuildozer.spec
file you provided. Also if you'll be using opencv's camera you gonna needopencv_extras
recipe alongsideopencv
. I did at least.Regarding to the error output you're getting.
TypeError
is almost always about the developer giving it the wrong thing or omitting something altogether. It complains about missing argument from what I've gathered. If you can share the relevant code block. I suspect you're missing an argument inpartial()
method of thefunctools
module but can't tell for sure without seeing the code block.
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 -- Android SDK Tools: ver. 2.0 (description: 'Android SDK Command-line Tools') -- Android SDK Build Tools: ver. 30.0.2 (subdir 30.0.2 from 30.0.2) CMake Error at cmake/android/OpenCVDetectAndroidSDK.cmake:176 (message): Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.
Use BUILD_ANDROID_PROJECTS=OFF to prepare Android project files without building them Call Stack (most recent call first): CMakeLists.txt:780 (include)
Please can anyone help with the issue. Exact same problem trying it out for 4days. CMake Error at cmake/android/OpenCVDetectAndroidSDK.cmake:176 (message): Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.
@abhishekju06 Follow the steps shared by @franslott :
Rename the folder
mv tools old-tools
Install missing dependencies & the famous tools
:
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "tools"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platforms;android-29"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platform-tools"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "patcher;v4"
sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "emulator"
Don't forget to replace <USERNAME>
with your username otherwise the command will error out.
I know how frustrating it can be to get OpenCV to work on Android using Python. Follow the steps and it's gonna work.
@abhishekju06 Follow the steps shared by @franslott :
- Rename the folder
mv tools old-tools
- Install missing dependencies & the famous
tools
:sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "tools" sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3" sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platforms;android-29" sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "platform-tools" sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "patcher;v4" sudo ./sdkmanager --sdk_root=/home/<USERNAME>/.buildozer/android/platform/android-sdk/ --install "emulator"
Don't forget to replace
<USERNAME>
with your username otherwise the command will error out.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, I am experiencing this error sdkmanager: command not found I have set export PATH=$PATH:~/.local/bin/ in my .bashrc Would you please help me ??
Note:After unzipping the commandlinetools-linux-6858069_latest.zip there is a folder named cmdline-tools
@abhishekju06 Can you please confirm that you ran sudo apt install android-sdk -y
?
@abhishekju06 Can you please confirm that you ran
sudo apt install android-sdk -y
?
I ran it just now My OS is Ubuntu 18.04 android-sdk is already the newest version (25.0.0+10~18.04.2). The following packages were automatically installed and are no longer required: libllvm7 libllvm9 libllvm9:i386 libnvidia-cfg1-430 libnvidia-cfg1-440 libnvidia-common-430 libnvidia-common-440 libnvidia-compute-430 libnvidia-compute-430:i386 libnvidia-compute-440 libnvidia-compute-440:i386 libnvidia-decode-430 libnvidia-decode-430:i386 libnvidia-decode-440 libnvidia-decode-440:i386 libnvidia-encode-430 libnvidia-encode-430:i386 libnvidia-encode-440 libnvidia-encode-440:i386 libnvidia-extra-440 libnvidia-fbc1-430 libnvidia-fbc1-430:i386 libnvidia-fbc1-440 libnvidia-fbc1-440:i386 libnvidia-gl-430 libnvidia-gl-430:i386 libnvidia-gl-440 libnvidia-gl-440:i386 libnvidia-ifr1-430 libnvidia-ifr1-430:i386 libnvidia-ifr1-440 libnvidia-ifr1-440:i386 libsdl-ttf2.0-0 libtorrent-rasterbar9 linux-hwe-5.4-headers-5.4.0-42 linux-hwe-5.4-headers-5.4.0-45 linux-hwe-5.4-headers-5.4.0-47 linux-hwe-5.4-headers-5.4.0-48 linux-hwe-5.4-headers-5.4.0-51 linux-hwe-5.4-headers-5.4.0-52 linux-hwe-5.4-headers-5.4.0-54 nvidia-compute-utils-430 nvidia-compute-utils-440 nvidia-dkms-430 nvidia-dkms-440 nvidia-utils-430 nvidia-utils-440 xserver-xorg-video-nvidia-430 xserver-xorg-video-nvidia-440
What are the next step that I should follow to run sdkmanager? Please help
@abhishekju06 Make sure you're running those commands from ~/.buildozer/android/platform/android-sdk/old_tools/bin
as it's where sdkmanager
program is located. It didn't work for me anywhere else.
@abhishekju06 Make sure you're running those commands from
~/.buildozer/android/platform/android-sdk/old_tools/bin
as it's wheresdkmanager
program is located. It didn't work for me anywhere else.
abhishek@abhishek:~/.buildozer/android/platform/android-sdk$ ls cmdline-tools commandlinetools-linux-6858069_latest.zip
there is no folder named tools when I unzip Should I run the command sdkmanager from cmdline-tools/bin If so this is the output abhishek@abhishek:~/.buildozer/android/platform/android-sdk/cmdline-tools/bin$ sdkmanager --list sdkmanager: command not found Though it contains the sdkmanager abhishek@abhishek:~/.buildozer/android/platform/android-sdk/cmdline-tools/bin$ ls -l total 40 -rwxr-xr-x 1 abhishek abhishek 5321 Jan 1 2010 apkanalyzer -rwxr-xr-x 1 abhishek abhishek 5312 Jan 1 2010 avdmanager -rwxr-xr-x 1 abhishek abhishek 5280 Jan 1 2010 lint -rwxr-xr-x 1 abhishek abhishek 5309 Jan 1 2010 screenshot2 -rwxr-xr-x 1 abhishek abhishek 5319 Jan 1 2010 sdkmanager
@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
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