1

The python version is 3.10.17, buildozer 1.5.0, kivy 2.3.1. Here is the requirements in buildozer.spec:

requirements = python3=3.10,kivy,openssl=3.0.16,cryptography==42.0.5,pyjnius @ git+https://github.com/kivy/pyjnius.git@eaf76a5#egg=pyjnius

Here is the buildozer.spec:

[app]

# (str) Title of your application
title = Video Monitor Front

# (str) Package name
package.name = myapp

# (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=3.10,kivy,openssl=3.0.16,cryptography==42.0.5,pyjnius @ git+https://github.com/kivy/pyjnius.git@eaf76a5#egg=pyjnius

#
android.api = 34
android.minapi = 21
android.ndk_path = /Users/macbook/Library/Android/sdk/ndk/25.2.9519653
android.sdk_path = /Users/macbook/Library/Android/sdk
p4a.branch = develop
android.archs = arm64-v8a
android.extra_patches = 
    patches/pyjnius_long_fix.patch:pyjnius

# (list) Supported orientations
# Valid options are: landscape, portrait, portrait-reverse or landscape-reverse
orientation = portrait


#
# 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 = 1.9.1

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 
android.python = 3.10  # Explicitly set Python version

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

#
# Python for android (p4a) specific
#


#
# 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

Also tried pyjnius without specifying certain version. But the error is the same when buildozer android debug:

STDERR:


# Command failed: ['/Users/macbook/Documents/code/py/myapp/venv310/bin/python3.10', '-m', 'pythonforandroid.toolchain', 'create', '--dist_name=myapp', '--bootstrap=sdl2', '--requirements=python3,kivy,openssl=3.0.16,cryptography==39.0.1,pyopenssl', '--arch=arm64-v8a', '--arch=armeabi-v7a', '--copy-libs', '--color=always', '--storage-dir=/Users/macbook/Documents/code/py/myapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a', '--ndk-api=21', '--ignore-setup-py', '--debug']

The reason for the error is because pyjnius is not compatible with python 3. In pyjnius_utils.pxi, it still use long which is deprecated in python 3:

 if isinstance(arg, int) or (
            (isinstance(arg, long) and arg < 2147483648)):  //<<===long not supported in python 3

Tried the patch file below but it didn't work (same error about long):

diff --git a/jnius/jnius_utils.pxi b/jnius/jnius_utils.pxi
index eaf76a5..7f8b4a2 100644
--- a/jnius/jnius_utils.pxi
+++ b/jnius/jnius_utils.pxi
@@ -320,7 +320,7 @@
             continue
 
         if r == 'S' or r == 'I':
-            if isinstance(arg, int) or (
-                    (isinstance(arg, long) and arg < 2147483648)):
+            if (isinstance(arg, int) and 
+                    (arg < 2147483648)):
                 score += 10
                 continue

I check the pyjnius 1.6.1 and it says officially supporting python up to 3.13. How to fix this error?

1 Answer 1

2

I had the exact same issue. It appears this has been fixed but hasn't been officially released yet:
https://github.com/kivy/pyjnius/pull/753

https://github.com/kivy/kivy/commit/5a1b27d7d3bdee6cedb55440bfae9c4e66fb3c68

I just edited my local files with these changes and that fixed the issue.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi Matthew, what is the python version you are using? I downgraded python from 3.12 to 3.10 for compatibility.
can you provide more detail about your setup? There are still some issues when running buildozer android debug.
I'm using python 3.12.3, buildozer 1.5.0, and Kivy 2.3.1 Did you update each file? I would suggest examining the changes to each file and then updating your local copies with those changes. I did this for each file and my build problems were solved. Are you seeing another error not related to the "long" references mentioned above?
No, no error for long. Which version of openssl. do you use? I downgraded python 3.12 to 3.10 because of some compatibility issue with, I believe it is openssl. But I would like to use newest python as I can. The kivy app is using https and that's why openssl module is introduced in the kivy app.
Here is version for other modules used: android.skip_download = True android.accept_sdk_license = True android.ndk_version = 25b android.sdk_version = 34 android.api = 34 android.minapi = 21 android.ndk_path = /Users/macbook/Library/Android/sdk/ndk/25.2.9519653 android.sdk_path = /Users/macbook/Library/Android/sdk android.sdkmanager_path = /Users/macbook/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager p4a.branch = develop
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.