Kivy for android in action: pack OpenCV with buildozer

CryptoWatch-Kivy          1.13
Kivy 2.0.0
Kivy-Garden 0.1.4
kivy-garden.wordcloud 1.0.0
kivymd 0.104.2.dev0

Build OpenCV for kivy

The resolution is from franslott in github issue.

It seems the new version of buildozer updated the SDK tools and no longer supports packing the OpenCV with the default setting. So, we should settle the SDK by ourselves.

What can we do with OpenCV in Android:

  • loading/writing images
  • writing videos (some formats like avi)
  • facial detection with the camera opened by kivy

What we can’t do:

  • loading videos
  • open cameras
  • update images under threading (display)

Abilities of OpenCV were limited in android. Hope someone could solve the problems above soon.

#mv tools old-tools
# mv lib/external/com/android/tools lib/external/com/android/old-tools

# 1. Download [cmdlines-tools from google](https://developer.android.com/studio#cmdline-tools)

# 2. prepare the sdk by yourself
# export the path you'd like to place it
export PREFIX=/run/media/karobben/Data/Kivy2.0MD0.104.2.dP3.7.5
mkdir $PREFIX/.buildozer/android/platform/android-sdk
cd $PREFIX/.buildozer/android/platform/android-sdk/

cp ~/Downloads/commandlinetools-linux-7302050_latest.zip .
unzip commandlinetools-linux-7302050_latest.zip

# mv tools old-tools

cd cmdline-tools/bin

sudo ./sdkmanager --sdk_root=$PREFIX/.buildozer/android/platform/android-sdk/ --install "tools"
sudo ./sdkmanager --sdk_root=$PREFIX/.buildozer/android/platform/android-sdk/ --install "build-tools;29.0.0-rc3"
sudo ./sdkmanager --sdk_root=$PREFIX/.buildozer/android/platform/android-sdk/ --install "platforms;android-27"
sudo ./sdkmanager --sdk_root=$PREFIX/.buildozer/android/platform/android-sdk/ --install "platform-tools"
sudo ./sdkmanager --sdk_root=$PREFIX/.buildozer/android/platform/android-sdk/ --install "patcher;v4"
sudo ./sdkmanager --sdk_root=$PREFIX/.buildozer/android/platform/android-sdk/ --install "emulator"

sudo ./sdkmanager --sdk_root=$PREFIX/android-sdk/ --install "tools"
sudo ./sdkmanager --sdk_root=$PREFIX/android-sdk/ --install "build-tools;29.0.0-rc3"
sudo ./sdkmanager --sdk_root=$PREFIX/android-sdk/ --install "platforms;android-27"
sudo ./sdkmanager --sdk_root=$PREFIX/android-sdk/ --install "platform-tools"
sudo ./sdkmanager --sdk_root=$PREFIX/android-sdk/ --install "patcher;v4"
sudo ./sdkmanager --sdk_root=$PREFIX/android-sdk/ --install "emulator"

adding the path into buildozer.spc:

buildozer.spc
android.sdk_path = /run/media/ken/Data/Kivy2.0MD0.104.2.dP3.7.5/android-sdk/
# delete ANT, NDK again
buildozer android clean
buildozer distclean
buildozer -v android debug
# or buildozer android debug deploy run

Kivy for android in action: pack OpenCV with buildozer

https://karobben.github.io/2021/05/15/Python/kivy-inaction-tb-8/

Author

Karobben

Posted on

2021-05-15

Updated on

2024-01-11

Licensed under

Comments