1

I'm using Windows Subsystem for Linux ( WSL ) with :

  • Python3 3.8.10
  • pip 21.3.1

installed Pillow using pip :

python3 -m pip install --upgrade Pillow

buildozer.spec ( edited ) :

[app]

# (str) Title of your application
title = Screen_Recorder

# (str) Package name
package.name = screen_recorder

# (str) Package domain (needed for android/ios packaging)
package.domain = org.test

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas

# (str) Application versioning (method 1)
version = 0.1

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3, kivy==2.0.0, android, numpy, pillow, opencv==4.5.3, plyer, vidgear, colorlog, chardet, requests, idna, urllib3, tqdm, mss, pyscreenshot, EasyProcess, entrypoint2, jeepney, streamlink, isodate, iso3166, iso-639, pycryptodome, PySocks, websocket-client, urllib3
# lxml, libxcb

# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = all

#
# OSX Specific
#

#
# author = © Copyright Info

# change the major version of python used by the app
osx.python_version = 3

# Kivy version to use
osx.kivy_version = 2.0.0

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0

# (string) Presplash background color (for android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
# olive, purple, silver, teal.
android.presplash_color = #FFFFFF

# (list) Permissions
android.permissions = RECORD_AUDIO, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE

# (str) Android logcat filters to use
android.logcat_filters = *:S python:D

# (str) The Android arch to build for, choices: armeabi-v7a , arm64-v8a (tested not work for my phone Samsung Galaxy J7 Prime), x86 (tested can't even install Samsung Galaxy J7 Prime), x86_64 (issue when building -zlib -lxml)
android.arch = x86_64


# (bool) enables Android auto backup feature (Android API >=23)
android.allow_backup = True


#
# iOS specific
#

# (str) Path to a custom kivy-ios folder
#ios.kivy_ios_dir = ../kivy-ios
# Alternately, specify the URL and branch of a git checkout:
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master

# Another platform dependency: ios-deploy
# Uncomment to use a custom checkout
#ios.ios_deploy_dir = ../ios_deploy
# Or specify URL and branch
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.10.0

# (bool) Whether or not to sign the code
ios.codesign.allowed = false


[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2

# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1

library used in my project :

< GUI >

  • kivy

< general >

  • numpy

< img processing >

  • opencv==4.5.3
  • vidgear

< filechooser >

  • plyer

When Compiling to Android x86_64 using buildozer, it gives the following errors :

[INFO]:    Building Pillow for x86_64
[INFO]:    Pillow apparently isn't already in site-packages
[INFO]:    Building compiled components in Pillow
[INFO]:    -> directory context /mnt/c/Python/Python__GUI/Kivy/MyKivyScreenRecorderApp/Packages/Android/.buildozer/android/platform/build-x86_64/build/other_builds/Pillow/x86_64__ndk_target_21/Pillow
[INFO]:    -> running python3 setup.py build_ext -v                                                                                working:    https://pillow.readthedocs.io/en/latest/installation.html

Exception in thread background thread for pid 26935:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs) 
  File "/home/paul/.local/lib/python3.8/site-packages/sh.py", line 1683, in wrap
    fn(*rgs, **kwargs)
  File "/home/paul/.local/lib/python3.8/site-packages/sh.py", line 2662, in background_thread
    handle_exit_code(exit_code)
  File "/home/paul/.local/lib/python3.8/site-packages/sh.py", line 2349, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/home/paul/.local/lib/python3.8/site-packages/sh.py", line 905, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1:

  RAN: /mnt/c/Python/Python__GUI/Kivy/MyKivyScreenRecorderApp/Packages/Android/.buildozer/android/platform/build-x86_64/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v

  STDOUT:
running build_ext

The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.

Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html

// the other errors are similar

Paul Lam
  • 176
  • 2
  • 12

1 Answers1

0

Just want to suggest a solution for others as a reference when compiling to Android x86_64 ( compiled successfully , but don't know if it's work ) ( any other suggestions / answers is welcome : ) )

  • after the first build failed
  • in your project dir
  • go to ./.buildozer/android/platform/python-for-android/pythonforandroid/recipes/ to change the NDK and xlib path for required recipes
  • in e.g. ./Pillow/ or ./Python3/
  • find sth like :
ndk_lib_dir = join(self.ctx.ndk_platform, 'usr', 'lib')
zlib_lib_path = join(self.ctx.ndk_platform, 'usr', 'lib')
  • and comment or replace it with
ndk_lib_dir = join(self.ctx.ndk_platform, 'usr', 'lib64')
zlib_lib_path = join(self.ctx.ndk_platform, 'usr', 'lib64')
  • save it and try re-build the project

ref. :

Question : Android x86_64 instant crash with hello world app, missing zlib

docs. : grep

stackexchange question : How to search strings inside files like in Windows without search monkey?

stackoverflow question : How to grep and replace

Paul Lam
  • 176
  • 2
  • 12