Падает приложение APK собранное в Kivy и buildozer
Я успешно собрал приложение, но при запуске его на Андроиде оно пытается загрузиться и потом пропадает с экрана, но висит в запущенных приложениях. В buildozer.spec кроме названий приложения и пакета ничего не менял. Что я делаю не так?
main.py
import time
from kivy.app import App
from kivy.properties import Clock
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import Screen
import Variables
import streams
class MenuScreen(Screen):
def __init__(self, **kw):
super(MenuScreen, self).__init__(**kw)
colorbg1 = [0.145, 0.592, 0.933, 1]
colorbg2 = [0.11, 0.894, 0.894, 1]
colorbg3 = [0.965, 0.02, 0.337, 1]
Clock.schedule_interval(lambda dt: self.update1(), 1)
self.button1 = Button(text='Server', size_hint=(1.5, 1), background_color=(colorbg1))
self.button2 = Button(text='Status', size_hint=(0.2, 1), background_color=(colorbg2))
self.button3 = Button(text='Connect', size_hint=(0.2, 1))
self.button4 = Button(text='Reconnect', size_hint=(0.2, 1))
self.button5 = Button(text='Internet', size_hint=(0.4, 1), background_color=(colorbg1))
self.button6 = Button(text='Status', background_color=(colorbg2))
self.button7 = Button(text='')
self.button8 = Button(text='')
self.button9 = Button(text='Control', size_hint=(0.4, 1), background_color=(colorbg1))
self.button10 = Button(text='Status', size_hint=(0.2, 1), background_color=(colorbg2))
self.button11 = Button(text='Remote', size_hint=(0.2, 1))
self.button12 = Button(text='Auto', size_hint=(0.2, 1))
self.button13 = Button(text='Power', size_hint=(0.4, 1), background_color=(colorbg1))
self.button14 = Button(text='Status', background_color=(colorbg2))
self.button15 = Button(text='')
self.button16 = Button(text='')
self.button17 = Button(text='Tank state', size_hint=(1.5, 1), background_color=colorbg1)
self.button18 = Button(text='Status', size_hint=(0.2, 1), background_color=colorbg2)
self.button19 = Button(text='', size_hint=(0.2, 1))
self.button20 = Button(text='', size_hint=(0.2, 1))
self.button21 = Button(text='Pump state', size_hint=(0.4, 1), background_color=colorbg1)
self.button22 = Button(text='Status', background_color=(colorbg2))
self.button23 = Button(text='On')
self.button24 = Button(text='Off')
self.button25 = Button(text='Light sensor', size_hint=(1.5, 1), background_color=(colorbg1))
self.button26 = Button(text='Status', size_hint=(0.2, 1), background_color=(colorbg2))
self.button27 = Button(text='', size_hint=(0.2, 1))
self.button28 = Button(text='', size_hint=(0.2, 1))
self.button29 = Button(text='Sadok Relay', size_hint=(0.4, 1), background_color=(colorbg1))
self.button30 = Button(text='Status', background_color=(colorbg2))
self.button31 = Button(text='On')
self.button32 = Button(text='Off')
self.button33 = Button(text='Rear Relay', size_hint=(0.4, 1), background_color=(colorbg1))
self.button34 = Button(text='Status', background_color=(colorbg2))
self.button35 = Button(text='On')
self.button36 = Button(text='Off')
self.button37 = Button(text='4Relay 1', size_hint=(1.5, 1), background_color=(colorbg1))
self.button38 = Button(text='Status', size_hint=(0.2, 1), background_color=(colorbg2))
self.button39 = Button(text='On', size_hint=(0.2, 1))
self.button40 = Button(text='Off', size_hint=(0.2, 1))
self.button41 = Button(text='4Relay 2', size_hint=(0.4, 1), background_color=(colorbg1))
self.button42 = Button(text='Status', background_color=(colorbg2))
self.button43 = Button(text='On')
self.button44 = Button(text='Off')
self.button45 = Button(text='4Relay 3', size_hint=(1.5, 1), background_color=(colorbg1))
self.button46 = Button(text='Status', size_hint=(0.2, 1), background_color=(colorbg2))
self.button47 = Button(text='On', size_hint=(0.2, 1))
self.button48 = Button(text='Off', size_hint=(0.2, 1))
self.button49 = Button(text='4Relay 4', size_hint=(0.4, 1), background_color=(colorbg1))
self.button50 = Button(text='Status', background_color=(colorbg2))
self.button51 = Button(text='On')
self.button52 = Button(text='Off')
layout = GridLayout(cols=4, rows=13)
self.add_widget(layout)
layout.add_widget(self.button1)
layout.add_widget(self.button2)
layout.add_widget(self.button3)
layout.add_widget(self.button4)
layout.add_widget(self.button5)
layout.add_widget(self.button6)
layout.add_widget(self.button7)
layout.add_widget(self.button8)
layout.add_widget(self.button9)
layout.add_widget(self.button10)
layout.add_widget(self.button11)
layout.add_widget(self.button12)
layout.add_widget(self.button13)
layout.add_widget(self.button14)
layout.add_widget(self.button15)
layout.add_widget(self.button16)
layout.add_widget(self.button17)
layout.add_widget(self.button18)
layout.add_widget(self.button19)
layout.add_widget(self.button20)
layout.add_widget(self.button21)
layout.add_widget(self.button22)
layout.add_widget(self.button23)
layout.add_widget(self.button24)
layout.add_widget(self.button25)
layout.add_widget(self.button26)
layout.add_widget(self.button27)
layout.add_widget(self.button28)
layout.add_widget(self.button29)
layout.add_widget(self.button30)
layout.add_widget(self.button31)
layout.add_widget(self.button32)
layout.add_widget(self.button33)
layout.add_widget(self.button34)
layout.add_widget(self.button35)
layout.add_widget(self.button36)
layout.add_widget(self.button37)
layout.add_widget(self.button38)
layout.add_widget(self.button39)
layout.add_widget(self.button40)
layout.add_widget(self.button41)
layout.add_widget(self.button42)
layout.add_widget(self.button43)
layout.add_widget(self.button44)
layout.add_widget(self.button45)
layout.add_widget(self.button46)
layout.add_widget(self.button47)
layout.add_widget(self.button48)
layout.add_widget(self.button49)
layout.add_widget(self.button50)
layout.add_widget(self.button51)
layout.add_widget(self.button52)
# box.add_widget(Button(text='Two', on_press=lambda x: set_screen('add_food')))
def update1(self):
Clock.schedule_interval(lambda dt: one(self), 1)
def one(self):
self.button2.text = str(Variables.status_code_server_connections)
self.button6.text = str(Variables.state_internet_connections)
self.button10.text = str(Variables.change_recive)
self.button14.text = str('in work')
self.button18.text = str('in work')
self.button22.text = str('in work')
self.button26.text = str(Variables.receive_from_server1)
self.button30.text = str(Variables.receive_from_server2)
self.button34.text = str('in work')
self.button38.text = str(Variables.receive_from_server3)
self.button42.text = str(Variables.receive_from_server4)
self.button46.text = str(Variables.receive_from_server5)
self.button50.text = str(Variables.receive_from_server6)
class app1(App):
def build(self):
Clock.schedule_interval(lambda dt: self.update_time(), 1) # Call update time
Clock.schedule_interval(lambda dt: streams.start1(), 10)
Clock.schedule_interval(lambda dt: streams.start2(), 8)
Clock.schedule_interval(lambda dt: streams.check_Server_sensor_conections(), 20)
Clock.schedule_interval(lambda dt: streams.check_req(), 15)
return MenuScreen()
def update_time(self):
self.root.seconds_string = time.strftime("%S") # Update time
if __name__ == '__main__':
app1().run()
streams.py
import gc
import requests
import Variables
def start1():
try:
if Variables.status_code_server_connections == 200:
r4_0 = Variables.parsing_GPIO_4relay1
r4_1 = str(r4_0[0])
r4_2 = str(r4_0[1])
r4_3 = str(r4_0[2])
r4_4 = str(r4_0[3])
params = {'params': str(Variables.parsing_ESP1),
'params1': str(Variables.Sadok_Light1),
'params2_1': r4_1,
'params2_2': r4_2,
'params2_3': r4_3,
'params2_4': r4_4,
'control': 'home'}
print(params)
r = requests.get('http://f0555107.xsph.ru/index_mob.php', params=params, timeout=3.0)
Variables.counting_requaest += 1
r.encoding = "UTF8"
print('start1 = Ok')
print(r.text)
else:
print('start1 ' + Variables.time_now + ' Bad response, status_code= ' + str(
Variables.status_code_server_connections))
except:
pass
def start2():
try:
if Variables.status_code_server_connections == 200:
url = "http://f0555107.xsph.ru/hello.html"
r = requests.get(url, timeout=3.00)
Variables.counting_requaest += 1
r.encoding = "UTF8"
if r.status_code == 200:
print('start2 = Ok')
with open('response_server.html', 'w') as output_file:
output_file.write(r.text)
with open('response_server.txt', 'w') as output_file:
output_file.write(r.text)
text_file = open("response_server.html", "r")
lines = text_file.read().split(',')
print(lines)
# print(len(lines))
text_file.close()
Variables.receive_from_server = lines
Variables.receive_from_server1 = lines[0]
Variables.receive_from_server2 = lines[1]
Variables.receive_from_server3 = lines[2]
Variables.receive_from_server4 = lines[3]
Variables.receive_from_server5 = lines[4]
Variables.receive_from_server6 = lines[5]
Variables.receive_from_server7 = lines[6]
Variables.parsing_ESP1 = Variables.receive_from_server1
else:
Variables.state_exchange_data = r.status_code
# with open('controlling.txt', 'a') as output_file:
# output_file.write(Variables.time_now + str(lines) + '\n')
else:
with open('controlling.log.txt', 'w') as output_file:
output_file.write('start2 ' + Variables.time_now + ' Bad_status_code!' + '\n')
print('start2 ' + str(Variables.time_now) + ' Bad response, status_code= ' + str(
Variables.status_code_server_connections))
except:
pass
def check_Server_sensor_conections():
try:
rg = requests.get("http://f0555107.xsph.ru/hello.html") # резервный ('http://httpbin.org/get')
Variables.counting_requaest += 1
print('check server ' + str(rg.status_code))
if int(rg.status_code) == 200:
Variables.state_server_connections = 'Ok'
else:
Variables.state_server_connections = 'Error!'
Variables.status_code_server_connections = rg.status_code
rg.close()
del rg
except:
print('except! Server')
Variables.state_server_connections = 'Some error!'
pass
def check_req():
try:
r = requests.get('https://google.com/') # резервный ('http://httpbin.org/get')
print('check_reg ' + str(r.status_code))
if r.status_code == 200:
Variables.state_internet_connections = 'Ok'
print('check_reg')
else:
Variables.state_internet_connections = 'Error!'
print('check_reg')
Variables.status_code_check_req = r.status_code
gc.collect()
# root.after(3000, check_req)
except:
print('except! Internet')
Variables.state_internet_connections = 'some error!'
pass