使用 Python 3 和 Cython 0.25-2 编译 Kivy with Buildozer



我无法使用buildozer或p4a进行编译。我最接近的是使用构建器。

  • 我正在使用 kivy 1.10.1;
  • 赛通 0.25.2
  • 尝试使用android-ndk-16b和crystax-10.3.2。
  • 尝试还将 hostpython3 放在要求中,但也没有工作。

我的 buildozer.spec 的一部分:

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = sqlite3,python3crystax,kivy,datetime,plyer,ecdsa,paramiko,pyjnius
# (int) Android API to use
android.api = 19
# (int) Minimum API required
android.minapi = 13
# (int) Android SDK version to use
android.sdk = 20
# (str) Android NDK version to use
android.ndk = 10.3.2
# (bool) Use --private data storage (True) or --dir public storage (False)
android.private_storage = False
# (str) Android NDK directory (if empty, it will be automatically downloaded.)
android.ndk_path = /home/awulll/python-for-android/crystax-ndk-10.3.2/
# (str) Android SDK directory (if empty, it will be automatically downloaded.)
android.sdk_path = /home/awulll/Android/Sdk/

我得到的错误:

[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Getting Android API version from user argument
[INFO]:    Available Android APIs are (19, 28)
[INFO]:    Requested API target 19 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK
[INFO]:    Got NDK version from $ANDROIDNDKVER
[WARNING]: NDK version was set as r10.3.2, but checking the NDK dir claims it is 10.3.2.
[WARNING]: The build will try to continue, but it may fail and you should check that your setting is correct.
[WARNING]: If the NDK dir result is correct, you don't need to manually set the NDK ver.
[INFO]:    Using Crystax NDK r10.3.2
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv
[INFO]:    Found the following toolchain versions: ['4.9', '5', 'clang3.6', 'clang3.7']
[INFO]:    Picking the latest gcc toolchain, here 5
[INFO]:    Of the existing distributions, the following meet the given requirements:
[INFO]:     DAP_new: includes recipes (hostpython3crystax, sdl2_image, sdl2_mixer, sdl2_ttf, sqlite3, python3crystax, sdl2, six, pyjnius, kivy, ecdsa, paramiko, plyer, datetime), built for archs (armeabi-v7a)
[INFO]:    DAP_new has compatible recipes, using this one
[INFO]:    Of the existing distributions, the following meet the given requirements:
[INFO]:     DAP_new: includes recipes (hostpython3crystax, sdl2_image, sdl2_mixer, sdl2_ttf, sqlite3, python3crystax, sdl2, six, pyjnius, kivy, ecdsa, paramiko, plyer, datetime), built for archs (armeabi-v7a)
[INFO]:    DAP_new has compatible recipes, using this one
[INFO]:    -> directory context /home/awulll/dapapp_new/.buildozer/android/platform/build/dists/DAP_new
usage: toolchain.py [-h] [--private PRIVATE] --package PACKAGE --name NAME
[--numeric-version NUMERIC_VERSION] --version VERSION
[--orientation ORIENTATION] [--launcher] [--icon ICON]
[--permission PERMISSIONS [PERMISSIONS ...]]
[--meta-data META_DATA] [--presplash PRESPLASH]
[--presplash-color PRESPLASH_COLOR] [--wakelock]
[--window] [--blacklist BLACKLIST] [--whitelist WHITELIST]
[--add-jar ADD_JAR] [--add-aar ADD_AAR] [--depend DEPENDS]
[--sdk SDK_VERSION] [--minsdk MIN_SDK_VERSION]
[--intent-filters INTENT_FILTERS] [--service SERVICES]
[--add-source EXTRA_SOURCE_DIRS]
[--try-system-python-compile] [--no-compile-pyo] [--sign]
toolchain.py: error: unrecognized arguments: --dir /home/awulll/dapapp_new/.buildozer/android/app
b'Could not find hostpython, will not compile to .pyo (this is normal with python3)n'# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name DAP_new --name DAP_new --version 0.1 --package com.doatlanticoaopacifico.dap_new --android_api 19 --minsdk 13 --dir /home/awulll/dapapp_new/.buildozer/android/app --permission INTERNET --permission ACCESS_NETWORK_STATE --permission CAMERA --presplash /home/awulll/dapapp_new/./data/figura.png --icon /home/awulll/dapapp_new/./data/logo.png --orientation portrait --window --copy-libs --arch armeabi-v7a --color=always --storage-dir="/home/awulll/dapapp_new/.buildozer/android/platform/build"
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

有什么想法吗?

版 1:

我现在使用了:"android.private_storage = True"(之前是 False(,代码被编译了,但现在在我的 android 上很糟糕。

在编译结束时,我收到以下消息:

[DEBUG]:    BUILD SUCCESSFUL
[DEBUG]:    
[DEBUG]:    Total time: 3 mins 46.325 secs
[DEBUG]:    
[INFO]:    <- directory context /home/awulll/dapapp_new/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    # Copying APK to current directory
[INFO]:    # APK filename not found in build output, trying to guess
[INFO]:    # Found APK file: /home/awulll/dapapp_new/.buildozer/android/platform/build/dists/DAP_new/build/outputs/apk/DAP_new-debug.apk
[INFO]:    # Add version number to APK
[INFO]:    # APK renamed to DAP_new-0.1-debug.apk
[DEBUG]:   -> running cp /home/awulll/dapapp_new/.buildozer/android/platform/build/dists/DAP_new/build/outputs/apk/DAP_new-debug.apk DAP_new-0.1-debug.apk
b'Could not find hostpython, will not compile to .pyo (this is normal with python3)nNo compiled python is present to zip, skipping.nthis should only be the case if you are using the CrystaX pythonn'# Android packaging done!
# APK DAP_new-0.1-debug.apk available in the bin directory
# Run '/home/awulll/Android/Sdk/platform-tools/adb devices'
# Cwd None
* daemon not running; starting now at tcp:5037
* daemon started successfully
b'List of devices attachednn'# Application pushed.
# Application started.

版二:

在我的 logcat 中,我发现了加密错误,但是当我将其作为要求时,我无法编译。 日志猫:

10-15 18:09:58.498 25389 25406 I python  :  Traceback (most recent call last):
10-15 18:09:58.499 25389 25406 I python  :    File "main.py", line 12, in <module>
10-15 18:09:58.500 25389 25406 I python  :      import rotinas
10-15 18:09:58.501 25389 25406 I python  :    File "./rotinas.py", line 11, in <module>
10-15 18:09:58.503 25389 25406 I python  :      import paramiko
10-15 18:09:58.504 25389 25406 I python  :    File "/data/user/0/com.doatlanticoaopacifico.dap_new/files/app/crystax_python/site-packages/paramiko/__init__.py", line 22, in <module>
10-15 18:09:58.506 25389 25406 I python  :      from paramiko.transport import SecurityOptions, Transport
10-15 18:09:58.507 25389 25406 I python  :    File "/data/user/0/com.doatlanticoaopacifico.dap_new/files/app/crystax_python/site-packages/paramiko/transport.py", line 33, in <module>
10-15 18:09:58.511 25389 25406 I python  :      from cryptography.hazmat.backends import default_backend
10-15 18:09:58.512 25389 25406 I python  :  ImportError: No module named 'cryptography'
10-15 18:09:58.657 25389 25406 I python  : Python for android ended.

尝试使用加密作为要求时发现的新错误:

[INFO]:    No dist exists that meets your requirements, so one will be built.
[ERROR]:   Didn't find any valid dependency graphs.
[ERROR]:   This means that some of your requirements pull in conflicting dependencies.
[ERROR]:   Exiting.
# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=DAP_new --bootstrap=sdl2 --requirements=sqlite3,python3crystax,kivy,datetime,plyer,ecdsa,paramiko,cryptography,pyjnius --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/awulll/dapapp_new/.buildozer/android/platform/build"
# 

将 hostpython 包含在您的需求行中

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = hostpython3crystax

最新更新