Open osklars opened 4 years ago
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
this
This is definitely a real solution to 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. I think the issue thread should be closed
@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. Steps:
android.sdk_path = ~/Android/Sdk
Now run:
buildozer -v android debug
And the compilation should be successful this time. P4A used NDK r19c, API 27.
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 namedtools
. 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
this
This is definitely a real solution to 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. I think the issue thread should be closed
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 . I want to run this function . I want to get a frame image out of video in android kivy apk . is there any other option , and I tried ffmpeg too , it is not running in apk .
def thumforvideo(self , path ):
print(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3])
print(os.listdir())
print("started thumbnail making...."*(50))
# Read the video from specified path
cam = cv2.VideoCapture(path) # I GUESS THIS IS CAUSING ERROR
print("cam making ...."*(50)) # THIS LINE IS NOT RUNNING , "cam making ...."*(50) NOT PRINTED IN TERMINAL .
try:
# creating a folder named data
if not os.path.exists('data'):
os.makedirs('data')
print("data making "*(50))
# if not created then raise error
except OSError:
print ('Error: Creating directory of data')
# frame
currentframe = 0
done = False
while(True):
# reading from frame
ret,frame = cam.read()
print(ret)
print(frame)
print(done)
if ret and not done :
result = os.path.basename(path)[:-3] + "jpg"
# if video is still left continue creating images
name = result #'./data/frame' + str(currentframe) + '.jpg'
print('Creating...' + name)
# writing the extracted images
cv2.imwrite(name, frame)
# increasing counter so that it will
# show how many frames are created
currentframe += 1
done = True
else:
print("break..."*(50))
break
=======================ERROR====================================================
09-19 19:42:49.882 19580 19580 I python : 1
09-19 19:42:49.884 19580 19580 V PythonActivity: onResume()
09-19 19:42:49.884 19580 19580 V SDL : onResume()
09-19 19:42:49.889 2318 2412 V UiModeManager: switch night mode to 1
09-19 19:42:49.890 2521 2521 D GestureStubView: resetRenderProperty: showGestureStub
09-19 19:42:49.890 2521 2521 D GestureStubView: showGestureStub
09-19 19:42:49.890 2521 2521 D GestureStubView: resetRenderProperty: showGestureStub
09-19 19:42:49.890 2521 2521 D GestureStubView: showGestureStub
09-19 19:42:49.891 19690 19690 I python : 2021-09-19 14:12:49.885
09-19 19:42:49.891 19690 19690 I python : ['thumb2.jpg', 'maymain.pyc', 'gpsblinker.pyc', 'VID_20210808_193912.mp4', 'download.jpeg', '.kivy', 'pythont.png', 'kivymd', '0.jpg', 'resized_image.jpg', 'homemapview.pyc', 'VID_20210808_193912.jpg', 'pythonthumb.png', 'thumb.jpg', '.nomedia', 'thumbnailmaking.pyc', 'output.png', 'mmmm.pyc', 'data', 'homemapview.kv', 'buildozer.spec', 'iiimage.jpg', 'nameVID_20210808_193912.jpg', 'vt.pyc', 'mmaaiinn.pyc', 'private.version', 'videothumb.pyc', '_python_bundle', 'gpsblinker.kv', 'p4a_env_vars.txt', 'tempdata.ini', 'car_scene_v001.099.png', 'main.pyc', 'IMG_20190712_211756.jpg', 'kkkkmain.pyc', 'pythonthumb.jpg', 'tile.pyc', 'vvt.pyc', 'sitecustomize.pyc', 'ain.pyc', 'car_scene_v001.109.png', 'pycache', 'ico.pyc', 'imagepic.pyc']
09-19 19:42:49.891 19690 19690 I python : started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....started thumbnail making....
09-19 19:42:49.897 19580 19580 V SDL : onWindowFocusChanged(): true
09-19 19:42:49.897 19580 19580 V SDL : nativeResume()
09-19 19:42:49.898 2521 2521 D GestureStubView: gatherTransparentRegion: need render w:54 h:1404
09-19 19:42:49.898 2318 3569 I SensorService: check list, getPackageName org.libsdl.app.SDLSurface
09-19 19:42:49.903 2521 2521 D GestureStubView: gatherTransparentRegion: need render w:54 h:1404
09-19 19:42:49.904 19580 19675 I python : [ERROR ] [Image ] Not found
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