我在Ubuntu上使用kivy v1.10.1,buildozer 0.39和python 3.5.2。
我有一个非常基本的kivy应用程序
Future getImage(ImageSource imageSource) async {
// using your method of getting an image
final File image = await ImagePicker.pickImage(source: imageSource);
// getting a directory path for saving
final String path = await getApplicationDocumentsDirectory().path;
// copy the file to a new path
final File newImage = await image.copy('$path/image1.png');
setState(() {
_image = newImage;
});}
buildozer规范包括:
from kivy.app import App
from kivy.uix.screenmanager import Screen
from kivy.uix.button import Label
from kivy.lang import Builder
root = Builder.load_string('''
<MainFrame>:
Label:
text: 'Hello world'
''')
class MainFrame(Screen):
def __init__(self, **kwargs):
super(MainFrame, self).__init__(**kwargs)
class BasicApp(App):
def build(self):
return MainFrame()
if __name__ == '__main__':
BasicApp().run()
我可以使用buildozer构建APK,但是当我在android设备上运行它时,它似乎已加载,但随后停止了。
这似乎是logcat输出的相关部分
requirements = python3, kivy
完整的logcat文本位于:
有人可以指出问题的可能根源吗?
答案 0 :(得分:0)
logcat中的实际回溯是这一部分:
08-31 14:29:28.636 29017 29035 I python : Traceback (most recent call last):
08-31 14:29:28.636 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/app/main.py", line 21, in <module>
08-31 14:29:28.637 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/app.py", line 829, in run
08-31 14:29:28.637 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/app/main.py", line 18, in build
08-31 14:29:28.638 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/app/main.py", line 14, in __init__
08-31 14:29:28.638 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/relativelayout.py", line 265, in __init__
08-31 14:29:28.639 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/floatlayout.py", line 65, in __init__
08-31 14:29:28.639 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/layout.py", line 76, in __init__
08-31 14:29:28.639 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/widget.py", line 361, in __init__
08-31 14:29:28.640 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/widget.py", line 469, in apply_class_lang_rules
08-31 14:29:28.640 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/lang/builder.py", line 538, in apply
08-31 14:29:28.641 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/lang/builder.py", line 654, in _apply_rule
08-31 14:29:28.641 29017 29035 I python : File "kivy/_event.pyx", line 188, in kivy._event.EventDispatcher.__cinit__
08-31 14:29:28.641 29017 29035 I python : File "kivy/properties.pyx", line 447, in kivy.properties.Property.link
08-31 14:29:28.642 29017 29035 I python : File "kivy/properties.pyx", line 632, in kivy.properties.NumericProperty.init_storage
08-31 14:29:28.642 29017 29035 I python : File "kivy/properties.pyx", line 418, in kivy.properties.Property.init_storage
08-31 14:29:28.642 29017 29035 I python : File "kivy/properties.pyx", line 655, in kivy.properties.NumericProperty.convert
08-31 14:29:28.643 29017 29035 I python : File "kivy/properties.pyx", line 663, in kivy.properties.NumericProperty.parse_str
08-31 14:29:28.643 29017 29035 I python : File "kivy/properties.pyx", line 670, in kivy.properties.NumericProperty.parse_list
08-31 14:29:28.643 29017 29035 I python : File "kivy/properties.pyx", line 296, in kivy.properties.dpi2px
08-31 14:29:28.644 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/utils.py", line 505, in __get__
08-31 14:29:28.645 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/metrics.py", line 162, in dpi
08-31 14:29:28.645 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/jnius/__init__.py", line 12, in <module>
08-31 14:29:28.646 29017 29035 I python : ImportError: dlopen failed: library "libpython2.7.so" not found
08-31 14:29:28.646 29017 29035 I python : Python for android ended.
我不知道是什么原因造成的。看起来pyjnius与python2.7链接在一起,但我不知道为什么会这样(并且p4a应该特别注意不会发生这种情况)。这是您尝试的第一个版本吗?如果您清理所有内容并再次运行,会发生同样的事情吗?
答案 1 :(得分:0)
通过删除.buildozer文件夹并重新启动,解决了该问题。
我想我以前是这样的:
requirements = python2, kivy
在buildozer.spec中,当我遇到问题时,将其更改为:
requirements = python3, kivy
但未删除.buildozer文件夹。
这大概引起了问题中涉及的问题。
我提供了这个答案,以鼓励可能遇到类似问题的其他人删除.buildozer文件夹,并从干净的构建开始,然后再寻求帮助。我本来应该想到的。