Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python android上的Kivy应用程序崩溃_Python_Android_Kivy - Fatal编程技术网

Python android上的Kivy应用程序崩溃

Python android上的Kivy应用程序崩溃,python,android,kivy,Python,Android,Kivy,我正在尝试使用kivy创建一个移动翻译器。在windows上编译时,应用程序工作正常。当我尝试在android上运行时,它在加载屏幕后崩溃。如何解决这个问题 我的代码: from kivy.uix.button import Button from kivy.uix.anchorlayout import AnchorLayout from kivy.uix.boxlayout import BoxLayout from kivy.uix.textinput import TextInput f

我正在尝试使用kivy创建一个移动翻译器。在windows上编译时,应用程序工作正常。当我尝试在android上运行时,它在加载屏幕后崩溃。如何解决这个问题

我的代码:

from kivy.uix.button import Button
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
import requests

URL_AUTH = 'https://translate.yandex.net/api/v1.5/tr.json/getLangs?'
URL_TRANSLATE = 'https://translate.yandex.net/api/v1.5/tr.json/translate'
KEY = '[API key]'
LANG = 'en-ru'

# --- request translate
auth = requests.post(URL_TRANSLATE, data={'key': KEY, 'text': 'Translate', 'lang': LANG, }).text

# --- App
class translator(App):

    def translate(self, instance):
        # --- request translate
        auth = requests.post(URL_TRANSLATE, data={'key': KEY, 'text': input_text.text, 'lang': LANG, }).text
        print(auth)
        # --- Update text in Label
        self.output_text.text = str(auth)


    def build(self):
        al = AnchorLayout()
        bl = BoxLayout(orientation='vertical', size_hint=[0.9, 0.9])
        btn = Button(text='Translate', on_press=self.translate)
        global input_text
        input_text = TextInput(multiline=False, text='Enter text')
        self.output_text = Label(text=auth)

        bl.add_widget(input_text)
        bl.add_widget(self.output_text)
        bl.add_widget(btn)
        al.add_widget(bl)
        return al

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


UPD:我试图从代码中删除请求并编译。应用程序已启动

我可以找到问题。在编译到buildozer中时,需要在需求列表中指定请求

requirements = python3, kivy, requests

它发生的原因可能有数千种。您应该将手机连接到pc,并使用
buildozer android debug deploy run logcat
命令运行buildozer。然后您将在控制台中看到错误。申请开始