Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.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 加载后Kivy应用程序崩溃_Python_Android_Kivy_Buildozer_Recipe - Fatal编程技术网

Python 加载后Kivy应用程序崩溃

Python 加载后Kivy应用程序崩溃,python,android,kivy,buildozer,recipe,Python,Android,Kivy,Buildozer,Recipe,我是一名工程学士的学生,还在读第二年,但我正在尝试使用Python和Kivy开发一个基本的助手应用程序(我尝试自己学习) 我为这个应用程序编写了代码,它在我的windows系统上运行得非常好,但是为了将源代码打包到apk中,我使用了Google Collab帐户并安装了Ubuntu和buildozer环境。apk也成功生成,但在任何android设备上安装后,应用程序在显示“(Kivy徽标)加载后立即崩溃…” 我试图更改部分代码和规范文件内容,但没有任何帮助。 我是Kivy和应用程序开发的新手,

我是一名工程学士的学生,还在读第二年,但我正在尝试使用Python和Kivy开发一个基本的助手应用程序(我尝试自己学习)

我为这个应用程序编写了代码,它在我的windows系统上运行得非常好,但是为了将源代码打包到apk中,我使用了Google Collab帐户并安装了Ubuntu和buildozer环境。apk也成功生成,但在任何android设备上安装后,应用程序在显示“(Kivy徽标)加载后立即崩溃…”

我试图更改部分代码和规范文件内容,但没有任何帮助。 我是Kivy和应用程序开发的新手,所以我(老实说)对logcat和apk的调试不太了解

如果有人能帮我,我将不胜感激

这是我的代码:


from kivy.app import App
from kivy.config import Config
Config.set('graphics','resizable',True)
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.pagelayout import PageLayout
from kivy.uix.gridlayout import GridLayout
import datetime
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
import os
from kivy.clock import Clock
from kivy.core.window import Window

OldNameOfFile=""
OldText=""
firsttime=1
pcheck=0
FileListString=""

class MyLayout(FloatLayout):
    def ButtonMaker(self):
        self.Timeb=Button(
            text="Time",size_hint=(.3,.3),pos_hint={"x":.09,"y":.6})
        self.WriteB=Button(
            text="Press here to \nwrite a note",size_hint=(.3,.3),pos_hint={"x":.6,"y":.6})
        self.NoteB=Button(
            text="Press here to view\n a written note",size_hint=(.3,.3),pos_hint={"x":.09,"y":.2})
        self.SWB=Button(
            text="Press here for \nStop-Watch",size_hint=(.3,.3),pos_hint={"x":.6,"y":.2})
        self.STOPWATCHStartB=Button(
            text="Start",size_hint=(.25,.20),pos_hint={"x":.04,"y":.3})
        self.STOPWATCHStopB=Button(
            text="Stop",size_hint=(.25,.20),pos_hint={"x":.36,"y":.3})
        self.STOPWATCHCloseB=Button(
            text="Close",size_hint=(.25,.20),pos_hint={"x":.68,"y":.3})
        self.STOPWATCHPauseB=Button(
            text="Pause",size_hint=(.25,.20),pos_hint={"x":.2,"y":.05})
        self.STOPWATCHResetB=Button(
            text="Reset",size_hint=(.25,.20),pos_hint={"x":.53,"y":.05})
        self.STOPWATCHDisp=TextInput(
            text=" 00:00:00:00",size_hint=(.9,.3),font_size='125sp',readonly=True,pos_hint={"x":.05,"y":.6})
        self.TimeBTime=Button(
            text="The time is :",background_color="black",font_size=40,pos_hint={"x":0,"y":.3})
        self.TimeBCloseB=Button(
            text="Click to close",size_hint=(.2,.2),pos_hint={"x":.35,"y":.2})
        self.WriteBNameB=Button(
            text="Enter name of file here : (or Enter name of already existing file to edit before entering text)",size_hint=(1,.09),background_color="black",pos_hint={"x":0.01,"y":.9})
        self.WriteBTIB=Button(
            text="Enter text here :",size_hint=(1,.09),background_color="black",pos_hint={"x":0.01,"y":.78})
        self.WriteBSubmitB=Button(
            text="Save",size_hint=(.4,.1),pos_hint={"x":0.07,"y":.1})
        self.WriteBCloseB=Button(
            text="Close",size_hint=(.4,.1),pos_hint={"x":.53,"y":.1})
        self.WriteBTI=TextInput(
            font_size=30,size_hint=(.95,.55),pos_hint={"x":0.02,"y":.25},multiline=True)
        self.WriteBName=TextInput(
            font_size=20,size_hint=(.95,.07),pos_hint={"x":0.02,"y":.85})
        self.WriteBp=Button(
            text="Empty name error...",background_color="black",size_hint=(.4,.08),pos_hint={"x":0.3,"y":0.01})
        self.NoteBName=TextInput(
            text="Select a file name from below files",font_size=20,size_hint=(.95,.07),pos_hint={"x":.02,"y":.85})
        self.NoteBNameB=Button(
            text="Enter name of file here :",size_hint=(1,.09),background_color="black",pos_hint={"x":0.01,"y":.9})
        self.NoteBTextData=TextInput(
            font_size=20,size_hint=(.95,.55),pos_hint={"x":0.02,"y":.25},readonly=True,multiline=True)
        self.NoteBTextDataB=Button(
            text="Data of files :",size_hint=(1,.09),background_color="black",pos_hint={"x":0.01,"y":.78})
        self.NoteBSubmitB=Button(
            text="Submit",size_hint=(.4,.1),pos_hint={"x":0.07,"y":.13})
        self.NoteBCloseB=Button(
            text="Close",size_hint=(.4,.1),pos_hint={"x":0.53,"y":.13})
        self.NoteBDeleteB=Button(
            text="Delete this",size_hint=(.38,.09),pos_hint={"x":0.3,"y":0.02})
        self.NoteBp=Button(
            text="Empty name error...",background_color="black",size_hint=(.4,.1),pos_hint={"x":0.3,"y":0.02})

        self.HomePage1List=[
            self.Timeb,self.WriteB,self.NoteB,self.SWB]
        self.STOPWATCHList=[
            self.STOPWATCHStartB,self.STOPWATCHStopB,self.STOPWATCHCloseB,self.STOPWATCHPauseB,self.STOPWATCHResetB,self.STOPWATCHDisp]
        self.TimeBList=[
            self.TimeBTime,self.TimeBCloseB]
        self.WriteBList=[
            self.WriteBNameB,self.WriteBTIB,self.WriteBName,self.WriteBTI,self.WriteBSubmitB,self.WriteBCloseB]
        self.NoteBList=[
            self.NoteBNameB,self.NoteBName,self.NoteBTextDataB,self.NoteBTextData,self.NoteBSubmitB,self.NoteBCloseB,self.NoteBDeleteB]
    def BindButtons(self):
        self.SWB.bind(on_press=self.StopWatchPress)
        self.Timeb.bind(on_press=self.TimeBPress)
        self.WriteB.bind(on_press=self.WriteBPress)
        self.NoteB.bind(on_press=self.NoteBPress)
        self.STOPWATCHStartB.bind(on_press=self.OnStart)
        self.STOPWATCHStopB.bind(on_press=self.OnStop)
        self.STOPWATCHResetB.bind(on_press=self.OnReset)
        self.STOPWATCHPauseB.bind(on_press=self.OnPause)
        self.STOPWATCHCloseB.bind(on_press=self.StopWatchClose)
        self.TimeBCloseB.bind(on_press=self.TimeBClose)
        self.WriteBCloseB.bind(on_press=self.WriteBClose)
        self.WriteBSubmitB.bind(on_press=self.Saveandwrite)
        self.NoteBSubmitB.bind(on_press=self.OpenFile)
        self.NoteBCloseB.bind(on_press=self.NoteBClose)
        self.NoteBDeleteB.bind(on_press=self.NoteBDelete)
    def AddHomePage1(self):
        for b in self.HomePage1List:
            self.add_widget(b)
    def RemHomePage1(self):
        for b in self.HomePage1List:
            self.remove_widget(b)

    def __init__(self,**kwargs):
        super().__init__(**kwargs)
        self.ButtonMaker()
        self.BindButtons()
        self.AddHomePage1()

    def StopWatchPress(self,button):
        self.RemHomePage1()
        self.STOPWATCHpause=0
        self.STOPWATCHstop=0
        Clock.unschedule(self.increment_STOPWATCHtime)
        self.STOPWATCHtime=["00","00","00","0"]
        self.STOPWATCHDisp.text=" 00:00:00:00"
        for b in self.STOPWATCHList:
            self.add_widget(b)
    def TimeBPress(self,button):
        self.RemHomePage1()
        time=datetime.datetime.now()
        time=time.strftime("%H:%M:%S")
        self.TimeBTime.text=self.TimeBTime.text[:13]+str(time)
        for b in self.TimeBList:
            self.add_widget(b)
    def WriteBPress(self,button):
        self.RemHomePage1()
        global firsttime
        firsttime=1
        for b in self.WriteBList:
            self.add_widget(b)
    def NoteBPress(self,button):
        self.RemHomePage1()
        path=os.getcwd()
        FileList=os.listdir(path)
        global FileListString
        FileListString="Names of all files are : \n"
        for k in FileList:
            if k[-4:]==".txt":
                FileListString=FileListString+k+"\n"
        self.NoteBTextData.text=FileListString
        for b in self.NoteBList:
            self.add_widget(b)

    def StopWatchClose(self,button):
        for b in self.STOPWATCHList:
            self.remove_widget(b)
        self.AddHomePage1()
    def TimeBClose(self,button):
        self.remove_widget(self.TimeBCloseB)
        self.remove_widget(self.TimeBTime)
        self.AddHomePage1()
    def Saveandwrite(self,button):
        global OldNameOfFile
        global OldText
        global firsttime
        if firsttime==1 or (OldNameOfFile!=self.WriteBName.text.strip() or OldText!=self.WriteBTI.text):
            file="new"
            NameOfFile=self.WriteBName.text.strip()
        else:
            file="old"
        if file=="old":
            return
        global pcheck
        OldNameOfFile=NameOfFile
        if NameOfFile=="":
            if pcheck==0:
                self.add_widget(self.WriteBp)
                pcheck=1
            return
        if NameOfFile!="":
            self.remove_widget(self.WriteBp)
            pcheck=0
        if NameOfFile[-4:]==".txt":
            NameOfFile=NameOfFile[:-4]
        try:
            NewF=open(NameOfFile+".txt","r")
            if self.WriteBTI.text=="":
                self.WriteBTI.text=NewF.read()
            NewF.close()
        except:
            pass
        NewF=open(NameOfFile+".txt","w")
        self.WriteBName.text=NameOfFile
        Text=self.WriteBTI.text
        OldText=Text
        NewF.write(Text)
        NewF.close()
        firsttime=0
        return
    def WriteBClose(self,button):
        for b in self.WriteBList:
            self.remove_widget(b)
        global pcheck
        global OldNameOfFile
        global firsttime
        firsttime=1
        OldNameOfFile=""
        self.WriteBName.text=""
        self.WriteBTI.text=""
        if pcheck==1:
            pcheck=0
            self.remove_widget(self.WriteBp)
        self.AddHomePage1()
    def OpenFile(self,button):
        global FileListString
        NameOfFile=self.NoteBName.text.strip()
        global pcheck
        if NameOfFile=="":
            if pcheck==0:
                self.add_widget(self.NoteBp)
                pcheck=1
            return
        if NameOfFile!="":
            self.remove_widget(self.NoteBp)
            pcheck=0
        try:
            if NameOfFile[-4:]==".txt":
                NameOfFile=NameOfFile[:-4]
            NewF=open(NameOfFile+".txt","r")
            self.NoteBTextData.text=NewF.read()
        except FileNotFoundError:
            self.NoteBTextData.text=FileListString
            self.NoteBName.text="No Such File.. Select a name from below files.."
    def NoteBDelete(self,button):
        NameOfFile=self.NoteBName.text.strip()
        if NameOfFile[-4:]==".txt":
            NameOfFile=NameOfFile[:-4]
        try:
            os.remove(NameOfFile+".txt")
        except:
            pass
        path=os.getcwd()
        FileList=os.listdir(path)
        global FileListString
        FileListString="Names of all files are : \n"
        for k in FileList:
            if k[-4:]==".txt":
                FileListString=FileListString+k+"\n"
        self.NoteBTextData.text=FileListString
        self.NoteBName.text="Select a file name from below files"
    def NoteBClose(self,button):
        for b in self.NoteBList:
            self.remove_widget(b)
        global pcheck
        global FileListString
        FileListString=""
        self.NoteBName.text="Select a file name from below files"
        if pcheck==1:
            pcheck=0
            self.remove_widget(self.NoteBp)
        self.AddHomePage1()
    def increment_STOPWATCHtime(self,interval):
        if int(self.STOPWATCHtime[3])<75:
            self.STOPWATCHtime[3]=str(int(self.STOPWATCHtime[3])+2)
        else:
            self.STOPWATCHtime[3]=str(int(self.STOPWATCHtime[3])+4)
        if int(self.STOPWATCHtime[3])>90:
            self.STOPWATCHtime[2]=str(int(self.STOPWATCHtime[2])+1)
            self.STOPWATCHtime[3]="00"
        if self.STOPWATCHtime[2]=="60":
            self.STOPWATCHtime[1]=str(int(self.STOPWATCHtime[1])+1)
            self.STOPWATCHtime[2]="00"
            self.STOPWATCHtime[3]="30"
        if self.STOPWATCHtime[1]=="60":
            self.STOPWATCHtime[0]=str(int(self.STOPWATCHtime[0])+1)
            self.STOPWATCHtime[1]="00"
        if self.STOPWATCHtime[0]=="24":
            self.STOPWATCHtime=["00","00","00","00"]
        for k in range(4):
            if int(self.STOPWATCHtime[k])<10:
                self.STOPWATCHtime[k]="0"+str(int(self.STOPWATCHtime[k]))
        self.STOPWATCHDisp.text=" "
        for k in range(4):
            self.STOPWATCHDisp.text+=self.STOPWATCHtime[k]
            if k<3: self.STOPWATCHDisp.text+=":"
    def OnPause(self,button):
        self.STOPWATCHpause=1
        Clock.unschedule(self.increment_STOPWATCHtime)
    def OnReset(self,button):
        Clock.unschedule(self.increment_STOPWATCHtime)
        self.STOPWATCHtime=["00","00","00","00"]
        self.STOPWATCHDisp.text=" 00:00:00:00"
        self.STOPWATCHpause=0
    def OnStart(self,button):
        Clock.unschedule(self.increment_STOPWATCHtime)
        if self.STOPWATCHpause==0 and self.STOPWATCHstop!=1:
            self.STOPWATCHtime=["00","00","00","00"]
            self.STOPWATCHDisp.text=" 00:00:00:00"
        elif self.STOPWATCHstop==1:
            self.STOPWATCHtime=["00","00","00","00"]
            self.STOPWATCHDisp.text=" 00:00:00:00"
        Clock.schedule_interval(self.increment_STOPWATCHtime,0.02)
        self.STOPWATCHpause=0
        self.STOPWATCHstop=0
    def OnStop(self,button):
        Clock.unschedule(self.increment_STOPWATCHtime)
        self.STOPWATCHstop=1
        self.STOPWATCHpause=0

class DemoApp(App):
    def build(self):
        return MyLayout()


if __name__=="__main__":
    demo=DemoApp()
    demo.run()

从kivy.app导入应用程序
从kivy.config导入配置
Config.set('graphics','resizable',True)
从kivy.uix.button导入按钮
从kivy.uix.floatlayout导入floatlayout
从kivy.uix.pagelayout导入pagelayout
从kivy.uix.gridlayout导入gridlayout
导入日期时间
从kivy.uix.popup导入弹出窗口
从kivy.uix.label导入标签
从kivy.uix.textinput导入textinput
导入操作系统
从kivy.clock导入时钟
从kivy.core.window导入窗口
OldNameOfFile=“”
OldText=“”
第一次=1
pcheck=0
FileListString=“”
类MyLayout(浮动布局):
def按钮制造商(自身):
self.Timeb=按钮(
text=“Time”,size\u hint=(.3.3),pos\u hint={“x”:.09,“y”:.6})
self.WriteB=按钮(
text=“按此处编写备忘”,大小提示=(.3.3),位置提示={“x”:.6,“y”:.6})
self.NoteB=按钮(
text=“按此处查看书面备忘”,大小提示=(.3.3),位置提示={“x”:.09,“y”:.2})
self.SWB=按钮(
text=“按下此处查看停止手表”,大小提示=(.3.3),位置提示={“x”:.6,“y”:.2})
self.STOPWATCHStartB=按钮(
text=“Start”,size\u hint=(.25.20),pos\u hint={“x”:.04,“y”:.3})
self.STOPWATCHStopB=按钮(
text=“Stop”,size\u hint=(.25.20),pos\u hint={“x”:.36,“y”:.3})
self.STOPWATCHCloseB=按钮(
text=“Close”,size_hint=(.25.20),pos_hint={“x”:.68,“y”:.3})
self.STOPWATCHPauseB=按钮(
text=“Pause”,size\u hint=(.25.20),pos\u hint={“x”:.2,“y”:.05})
self.STOPWATCHResetB=按钮(
text=“Reset”,size_hint=(.25.20),pos_hint={“x”:.53,“y”:.05})
self.STOPWATCHDisp=TextInput(
text=“00:00:00:00”,size_-hint=(.9.3),font_-size='125sp',readonly=True,pos_-hint={“x”:.05,“y”:.6})
self.TimeBTime=按钮(
text=“时间是:”,background\u color=“black”,font\u size=40,pos\u hint={“x”:0,“y”:.3})
self.TimeBCloseB=按钮(
text=“单击关闭”,大小提示=(.2.2),位置提示={“x”:.35,“y”:.2})
self.WriteBNameB=按钮(
text=“在此处输入文件名:(或在输入文本之前输入要编辑的现有文件名)”,size\u hint=(1.09),background\u color=“black”,pos\u hint={“x”:0.01,“y”:.9})
self.WriteBTIB=按钮(
text=“在此处输入text:”,size\u hint=(1.09),background\u color=“black”,pos\u hint={“x”:0.01,“y”:.78})
self.WriteBSubmitB=按钮(
text=“Save”,size_hint=(.4.1),pos_hint={“x”:0.07,“y”:.1})
self.WriteBCloseB=按钮(
text=“Close”,size_hint=(.4.1),pos_hint={“x”:.53,“y”:.1})
self.WriteBTI=TextInput(
字体大小=30,大小提示=(.95.55),位置提示={“x”:0.02,“y”:.25},多行=True)
self.WriteBName=TextInput(
字体大小=20,大小提示=(.95.07),位置提示={“x”:0.02,“y”:.85})
self.WriteBp=按钮(
text=“空名称错误…”,background\u color=“black”,size\u hint=(.4.08),pos\u hint={“x”:0.3,“y”:0.01})
self.NoteBName=TextInput(
text=“从下面的文件中选择一个文件名”,font_size=20,size_hint=(.95.07),pos_hint={“x”:.02,“y”:.85})
self.NoteBNameB=按钮(
text=“在此处输入文件名:”,size\u hint=(1.09),background\u color=“black”,pos\u hint={“x”:0.01,“y”:.9})
self.NoteBTextData=TextInput(
font_size=20,size_hint=(.95.55),pos_hint={“x”:0.02,“y”:.25},readonly=True,multiline=True)
self.NoteBTextDataB=按钮(
text=“文件数据:”,size\u hint=(1.09),background\u color=“black”,pos\u hint={“x”:0.01,“y”:.78})
self.NoteBSubmitB=按钮(
text=“提交”,大小提示=(.4.1),位置提示={“x”:0.07,“y”:.13})
self.NoteBCloseB=按钮(
text=“Close”,size_hint=(.4.1),pos_hint={“x”:0.53,“y”:.13})
self.NoteBDeleteB=按钮(
text=“删除此”,大小提示=(.38.09),位置提示={“x”:0.3,“y”:0.02})
self.NoteBp=按钮(
text=“空名称错误…”,background\u color=“black”,size\u hint=(.4.1),pos\u hint={“x”:0.3,“y”:0.02})
自我主页列表=[
self.Timeb,self.WriteB,self.NoteB,self.SWB]
自动秒表=[
self.STOPWATCHStartB,self.STOPWATCHStopB,self.STOPWATCHCloseB,self.STOPWATCHPauseB,self.STOPWATCHResetB,self.STOPWATCHDisp]
自我时间列表=[
self.timeb时间,self.timeb关闭]
self.WriteBList=[
self.WriteBNameB,self.WriteBTIB,self.WriteBName,self.WriteBTI,self.WriteBSubmitB,self.WriteBCloseB]
自我注释列表=[
self.NoteBNameB、self.NoteBName、self.NoteBTextDataB、self.NoteBTextData、self.NoteBSubmitB、self.NoteBCloseB、self.NoteBDeleteB]
def绑定按钮(自):
self.SWB.bind(on_press=self.StopWatchPress)
self.Timeb.bind(on_press=self.Timeb press)
self.WriteB.bind(on_press=self.WriteBPress)
self.NoteB.bind(按=self.NoteBPress)
self.STOPWATCHStartB.bind(按=self.OnStart时)
self.STOPWATCHStopB.bind(按=self.OnStop)
self.STOPWATCHResetB.bind(按=self.OnReset)
self.STOPWATCHPauseB.bind(按=self.OnPause)
self.STOPWATCHCloseB.bind(按=self.StopWatchClose时)
self.TimeBCl