Buildozer编译简单的android kivy应用程序,但在打包时失败

时间:2014-03-11 21:16:13

标签: python-2.7 kivy

这是buildozer的输出:

buildozer android debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Install platform
# Apache ANT found at /root/.buildozer/android/platform/apache-ant-1.8.4
# Android SDK found at /root/.buildozer/android/platform/android-sdk-21
# Android NDK found at /root/.buildozer/android/platform/android-ndk-r9c
# Android packages already installed.
# Check application requirements
# Compile platform
# Distribution compiled.
# Build the application #1
# Package the application
Traceback (most recent call last):
  File "/bin/buildozer", line 5, in <module>
    run()
  File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 1215, in run
        Buildozer().run_command(sys.argv[1:])
  File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 842, in run_command
    self.target.run_commands(args)
  File "/usr/lib/python2.7/site-packages/buildozer/target.py", line 85, in run_commands
    func(args)
  File "/usr/lib/python2.7/site-packages/buildozer/target.py", line 97, in cmd_debug
    self.buildozer.build()
  File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 178, in build
    self.target.build_package()
  File "/usr/lib/python2.7/site-packages/buildozer/targets/android.py", line 397, in build_package
    version = self.buildozer.get_version()
  File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 554, in     get_version
    ' (looking for `{1}`)'.format(fn, regex))
    Exception: Unable to find capture version in ./main.py
 (looking for `__version__ = '(.*)'`)

我试图编译一个我设计的简单概率计算器。我无法发布代码,因为我会尝试发布代码。但是,我愿意回答任何我需要的问题才能让它发挥作用。

根据buildozer的输出判断,我它在main.py中寻找一条我不知道我需要的行。不幸的是,我不知道那条线会是什么样子。但是,在buildozer.spec中,有一行说明了这一点:

version.regex = __version__ = '(.*)'
version.filename = %(source.dir)s/main.py

第一行看起来像输出中的行,第二行引用main.py文件。有谁知道这些线是什么意思?我是buildozer的新手,所以我不太清楚在这里做什么。在此先感谢您的帮助。

2 个答案:

答案 0 :(得分:10)

默认情况下,buildozer会在您的main.py中查找__version__ = 'something'形式的一行。这用于设置apk版本,一个必填字段。

您可以将此行添加到main.py中,也可以注释掉版本检查,并在buildozer.spec的下一行中取消注释替代版本方法。这允许您在buildozer.spec本身中设置版本字符串。

答案 1 :(得分:0)

在main.py文件的顶部添加版本 ='0.1',以便您可以打包应用程序而不会出现任何错误。