我已经尝试构建APK三天了。一般来说,我是Linux的新手,我遵循了本教程:https://www.youtube.com/watch?v=kcte8vcGMSU我做的每件事都像他展示的那样,唯一的区别是我不能像他那样安装kivy,我用另一种方式安装了它,但它有效,我可以从终端运行我的main.py。无论如何,buildozer init是有效的,但当我尝试使用buildozer android调试时,会弹出以下错误:
Traceback (most recent call last):
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 567, in _build_master
ws.require(__requires__)
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 884, in require
needed = self.resolve(parse_requirements(requirements))
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 775, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (buildozer 0.38.dev0 (/home/rain/.local/lib/python3.8/site-packages), Requirement.parse('buildozer==1.2.0.dev0'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/buildozer", line 33, in <module>
sys.exit(load_entry_point('buildozer==1.2.0.dev0', 'console_scripts', 'buildozer')())
File "/home/rain/.local/lib/python3.8/site-packages/buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/home/rain/.local/lib/python3.8/site-packages/buildozer/__init__.py", line 1053, in run_command
targets = [x[0] for x in self.targets()]
File "/home/rain/.local/lib/python3.8/site-packages/buildozer/__init__.py", line 1053, in <listcomp>
targets = [x[0] for x in self.targets()]
File "/home/rain/.local/lib/python3.8/site-packages/buildozer/__init__.py", line 944, in targets
m = __import__('buildozer.targets.{0}'.format(target),
File "/home/rain/.local/lib/python3.8/site-packages/buildozer/targets/android.py", line 41, in <module>
from distutils.version import LooseVersion
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
File "<frozen importlib._bootstrap>", line 556, in module_from_spec
File "/home/rain/.local/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 83, in create_module
return importlib.import_module('setuptools._distutils')
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/rain/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 16, in <module>
import setuptools.version
File "/home/rain/.local/lib/python3.8/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3239, in <module>
def _initialize_master_working_set():
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3222, in _call_aside
f(*args, **kwargs)
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3251, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 569, in _build_master
return cls._build_from_requirements(__requires__)
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 582, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 770, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'buildozer==1.2.0.dev0' distribution was not found and is required by the application
对不起,我是新来的,我只是真的很困惑和无助。如有任何帮助,我们将不胜感激。在虚拟机中使用最新版本的Ubuntu。
这可能是因为您使用的是python 3.8尝试python 3.6,并确保不仅安装python3.6,还将主python版本更改为3.6
如何安装python很容易找到,所以我不会讨论
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0
sudo update-alternatives --install /usr/bin/python python3 /usr/bin/python3.6 0
最后一个数字0是优先级,如果以上不起作用,请尝试1或2
这是如何更改主python版本
为Buildozer克隆GitHub repo后,将目录更改为/Buildozer文件夹。
现在运行sudo python3 setup.py install
如果您还没有安装Python的setuptools,请首先通过sudo apt-get install -y python3-setuptools
安装它们,然后再次运行上一个命令。
现在,您可以开始将项目转换为APK。确保项目文件夹在此/buildozer目录中。