Kivy Plyer GPS JVM例外

时间:2015-06-01 06:59:35

标签: android gps kivy

我正在Kivy编写GPS飞机导航应用程序。它在我测试过的所有设备上运行良好,包括各种手机和三星Galaxy Tab 4 10.1"但在三星Galaxy Tab 4 8"上失败了。假设有故障的设备我把它发回去并得到另一个。同样的问题。

使用Tito的GPSdemo应用程序并捕获异常, 在self.gps.start()行抛出:

File "jnius_utils.pxi", line 43, in jnius.jnius.check_exception 
(jnius/jnius.c3316) JavaException: JVM exception occured.

8" tab是我的应用程序的一个很好的设备,所以我想使用它。其他GPS应用可以正常工作,例如GPS Arrow Pro和Sky Demon。

我有什么想法可以解决这个问题吗?

The code is:
from kivy.lang import Builder
from plyer import gps
from kivy.app import App
from kivy.properties import StringProperty
from kivy.clock import Clock

kv = '''
BoxLayout:
    orientation: 'vertical'
    Label:
        text: app.gps_location
    Label:
        text: app.gps_status
    BoxLayout:
        size_hint_y: None
        height: '48dp'
        padding: '4dp'
        ToggleButton:
            text: 'Start' if self.state == 'normal' else 'Stop'
            on_state: app.gps.start() if self.state == 'down' else app.gps.stop()
'''

class GpsTest(App):

    gps_location = StringProperty()
    gps_status = StringProperty('')

    def build(self):
        self.gps = gps
        try:
            self.gps.configure(on_location=self.on_location, on_status=self.on_status)
            self.gps.start() #exception occurs here 
        except:
            import traceback;
            import sys; 
            formatted_lines = traceback.format_exc().splitlines()
            self.gps_status = formatted_lines[-2]+'\n'+formatted_lines[-1]
            print self.gps_status

        return Builder.load_string(kv)

    def on_location(self, **kwargs):
        self.gps_location = '\n'.join(['{}={}'.format(k, v) for k, v in kwargs.items()])

    def on_status(self, stype, status):
        self.gps_status = 'type={}\n{}'.format(stype, status)

if __name__ == '__main__':
    GpsTest().run()

0 个答案:

没有答案
相关问题