Description
Checklist
- the issue is indeed a bug and not a support request
- issue doesn't already exist: https://github.com/kivy/python-for-android/issues
- I have a short, runnable example that reproduces the issue
- I reproduced the problem with the latest development version (
p4a.branch = develop
) - I used the grave accent (aka backticks) to format code or logs when appropriated
Versions
- Python: 3.11.5
- OS: Ubuntu
- Kivy: 2.2.1
- Cython: 0.29.36
- OpenJDK: 17
Description
I had an issue compiling my kivy application to .apk
, after a lot of fiddling, I received the solution in the discord channel for the python-for-android
project. (The content of the application does not matter, as the error happens for the basic application described in kivy's docs).
When running the error on my device I received the error ImportError: dlopen failed: "/data/data/org.uriyaharpeness.neverfever/files/app/_python_bundle/site-packages/kivy/_clock.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)
, which was caused apparently because of the way I specified the requirements - using ~=
.
I now know the reason for the failure, which can be seen here:
https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/toolchain.py#L654-L662
The parsing of the requirements supports only no constraints or exact version (==
) of the packages, and not all the specifications pip supports, which I intuitively used for my requirements.
I have not seen any reference to that issue in the documentation, not a useful comment about this limitation in the buildozer.spec
file. I would like to suggest a few mitigation steps, for all those theoretical poor souls who could run into the same issue:
- In the documentation of buildozer - specify that only no constrains or exact version are supported for the requirements.
- In the initial
buildozer.spec
file - include this limitation in the comment. - In the parsing function, called upon compiling - raise an indicative exception if the above requirements are not met.
I would happily try to open a PR for all of these suggestions, but would first like to get some consensus.
"The first step in solving a problem is to recognize that it does exist."
- Zig Ziglar
buildozer.spec
Command:
buildozer android debug
Spec file:
...
requirements = python3,kivy~=2.2.1
...
Logs
...
12-06 16:25:57.472 31566 8670 I python : [ERROR ] [Clock ] Unable to import kivy._clock. Have you perhaps forgotten to compile kivy? Kivy contains Cython code which needs to be compiled. A missing kivy._clock often indicates the Cython code has not been compiled. Please follow the installation instructions and make sure to compile Kivy
12-06 16:25:57.473 31566 8670 I python : Traceback (most recent call last):
12-06 16:25:57.473 31566 8670 I python : File "/home/runner/work/myapp/myapp/.buildozer/android/app/main.py", line 1, in <module>
12-06 16:25:57.475 31566 8670 I python : File "/home/runner/work/myapp/myapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/neverfever/arm64-v8a/kivy/clock.py", line 466, in <module>
12-06 16:25:57.476 31566 8670 I python : ImportError: dlopen failed: "/data/data/org.uriyaharpeness.neverfever/files/app/_python_bundle/site-packages/kivy/_clock.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)
12-06 16:25:57.476 31566 8670 I python : Python for android ended.