在Android上注意到Kivy应用的以下问题。示例代码取自Kivy Basic documentation:
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
class LoginScreen(GridLayout):
def __init__(self, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text='User Name'))
self.username = TextInput(multiline=False)
self.add_widget(self.username)
self.add_widget(Label(text='password'))
self.password = TextInput(password=True, multiline=False)
self.add_widget(self.password)
class MyApp(App):
def build(self):
return LoginScreen()
if __name__ == '__main__':
MyApp().run()
我正在使用新的P4A工具链($buildozer -v android_new debug deploy run
)。这是我构建应用程序的配置:
该应用运行正常,但只要输入任何数字(0-9)
就会崩溃。字符(a-z)
,即使是特殊字符,也能完美运行。在桌面上没有问题(Ubuntu 14.04)。
这在Android 6.0.1和Android 5.1.1(单独的设备)上都经过测试。
这是$adb logcat|grep python
的输出(仅限最后几行):
03-07 10:19:48.972 7842 7857 I python : [INFO ] [GL ] Texture max units <16>
03-07 10:19:48.976 7842 7857 I python : [INFO ] [Window ] auto add sdl2 input provider
03-07 10:19:48.978 7842 7857 I python : [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
03-07 10:19:48.981 7842 7857 W linker : /data/data/org.test.textinput_tester/files/app/lib/python2.7/site-packages/jnius/jnius.so: is missing DT_SONAME will use basename as a replacement: "jnius.so"
03-07 10:19:49.379 7842 7857 I python : [WARNING] [Base ] Unknown <android> provider
03-07 10:19:49.379 7842 7857 I python : [INFO ] [Base ] Start application main loop
03-07 10:19:49.383 7842 7857 I python : [INFO ] [GL ] NPOT texture support is available
03-07 10:19:49.386 7842 7857 I python : [ERROR ] [Base ] Failed to import "android" module. Could not remove android presplash.
03-07 10:20:14.940 7842 7857 I python : [INFO ] [Base ] Leaving application in progress...
03-07 10:20:14.941 7842 7857 I python : Traceback (most recent call last):
03-07 10:20:14.942 7842 7857 I python : File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/app/main.py", line 27, in <module>
03-07 10:20:14.944 7842 7857 I python : File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/app.py", line 828, in run
03-07 10:20:14.946 7842 7857 I python : File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/base.py", line 504, in runTouchApp
03-07 10:20:14.947 7842 7857 I python : File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 658, in mainloop
03-07 10:20:14.948 7842 7857 I python : File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 580, in _mainloop
03-07 10:20:14.950 7842 7857 I python : AttributeError: 'LogFile' object has no attribute 'encoding'
03-07 10:20:15.002 7842 7857 I python : Python for android ended.
在这方面的任何帮助将不胜感激。