Я тестирую Kivy с Buildozer, чтобы сделать небольшое приложение для моего устройства Android. На моем P C все работает правильно. Но когда я хочу создать APK с Buildozer каждый раз, я получаю сообщение об ошибке AttributeError: 'NoneType' object has no attribute 'text'
Я гуглял много раз, но не мог найти ответ на свой вопрос.
Кто-нибудь есть подсказка для меня?
Было бы здорово.
Спасибо!
main.py:
import kivy
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
import random
from kivy.clock import Clock
from kivy.properties import ObjectProperty
import requests
import json
def login (name,password):
url_login = 'URL'
payload = {'email': name, 'password': password}
headers = {'content-type': 'application/json'}
r = requests.post(url_login, data=json.dumps(payload), headers=headers).json()
return (r['token'])
token =login("ID","PW")
class ConnectPage(GridLayout):
oee = ObjectProperty(None)
performance = ObjectProperty(None)
quality = ObjectProperty(None)
availability = ObjectProperty(None)
sensorstandort = ObjectProperty(None)
schicht = ObjectProperty(None)
timestamp = ObjectProperty(None)
alert = ObjectProperty(None)
def oee_anzeige(self, *args):
#Anfrage an Server senden
url_report = 'URL/'
payload_report = {}
headers_report = {'content-type': 'application/json', 'Authorization': token}
r_report = requests.get(url_report, data=json.dumps(payload_report), headers=headers_report)
response = r_report.json()
#Schicht, Sensorstandort und ggfs. Störgrund raussuchen
x = 0
for i in response['included']:
if response['included'][x]['type'] == 'shift':
schicht = response['included'][x]['attributes']['name']
if response['included'][x]['type'] == 'location':
sensorstandort = response['included'][x]['attributes']['name']
if response['included'][x]['type'] == 'notification':
timestamp = str(response['included'][x]['attributes']['inserted-at'])
timestamp = timestamp[11:16] + ' Uhr'
#self.timestamp.text = timestamp
if response['included'][x]['attributes']['triggered-by'] == 'standstill':
self.alert.text = "Verfügbarkeitsverlust seit"
elif sensorstandort == response['included'][x]['attributes']['triggered-by'] == 'slowdown':
self.alert.text = "Leistungsverlust seit"
x +=1
#oee Werte aus API ziehen
oee = str(response['data']['attributes']['oee']) + " %"
availability = str(response['data']['attributes']['availability']) + " %"
performance =str(response['data']['attributes']['performance']) + " %"
quality = str(response['data']['attributes']['quality']) + " %"
#Labels definieren
self.oee.text = oee
self.availability.text = availability
self.performance.text = performance
self.quality.text = quality
self.sensorstandort.text = sensorstandort
self.schicht.text = schicht
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.cols = 2 # used for our grid
class EpicApp(App):
def build(self):
t = ConnectPage()
Clock.schedule_once(t.oee_anzeige, 2)
Clock.schedule_interval(t.oee_anzeige, 90)
return t
if __name__ == "__main__":
EpicApp().run()
Epi c .kv
<ConnectPage>:
oee:oee
availability: availability
performance: performance
quality: quality
sensorstandort: sensorstandort
schicht: schicht
alert: alert
timestamp: timestamp
GridLayout:
cols: 2
Label:
text: "wird geladen"
id: sensorstandort
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "wird geladen"
id: schicht
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "OEE"
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "wird geladen"
id: oee
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "Verfügbarkeit"
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "Wird geladen"
id: availability
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "Leistung"
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "Wird geladen"
id: performance
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "Qualität"
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text: "Wird geladen"
id: quality
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text:
id: alert
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Label:
text:
id: timestamp
text_size: self.width, None
size_hint: 1, None
height: self.texture_size[1]
Журнал от Buildozer Logcat:
....
04-01 19:37:22.029 19854 19881 I python : Traceback (most recent call last):
04-01 19:37:22.030 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 97, in <module>
04-01 19:37:22.031 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/app.py", line 855, in run
04-01 19:37:22.032 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp
04-01 19:37:22.034 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop
04-01 19:37:22.035 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop
04-01 19:37:22.035 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle
04-01 19:37:22.036 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py", line 591, in tick
04-01 19:37:22.037 19854 19881 I python : File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
04-01 19:37:22.037 19854 19881 I python : File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
04-01 19:37:22.038 19854 19881 I python : File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
04-01 19:37:22.039 19854 19881 I python : File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
04-01 19:37:22.040 19854 19881 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 52, in oee_anzeige
04-01 19:37:22.041 19854 19881 I python : AttributeError: 'NoneType' object has no attribute 'text'
04-01 19:37:22.041 19854 19881 I python : Python for android ended.
....
04-01 19:44:07.500 20768 20788 I python : Traceback (most recent call last):
04-01 19:44:07.501 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 97, in <module>
04-01 19:44:07.502 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/app.py", line 855, in run
04-01 19:44:07.503 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp
04-01 19:44:07.504 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop
04-01 19:44:07.504 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop
04-01 19:44:07.505 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle
04-01 19:44:07.505 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py", line 591, in tick
04-01 19:44:07.506 20768 20788 I python : File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
04-01 19:44:07.507 20768 20788 I python : File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
04-01 19:44:07.507 20768 20788 I python : File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
04-01 19:44:07.508 20768 20788 I python : File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
04-01 19:44:07.508 20768 20788 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 52, in oee_anzeige
04-01 19:44:07.509 20768 20788 I python : AttributeError: 'NoneType' object has no attribute 'text'
04-01 19:44:07.509 20768 20788 I python : Python for android ended.
04-01 19:48:13.346 21723 21762 I python : Initializing Python for Android
04-01 19:48:13.347 21723 21762 I python : Setting additional env vars from p4a_env_vars.txt
04-01 19:48:13.347 21723 21762 I python : Changing directory to the one provided by ANDROID_ARGUMENT
04-01 19:48:13.347 21723 21762 I python : /data/user/0/org.test.oeecloud/files/app
04-01 19:48:13.356 21723 21762 I python : Preparing to initialize python
04-01 19:48:13.356 21723 21762 I python : _python_bundle dir exists
04-01 19:48:13.356 21723 21762 I python : calculated paths to be...
04-01 19:48:13.356 21723 21762 I python : /data/user/0/org.test.oeecloud/files/app/_python_bundle/stdlib.zip:/data/user/0/org.test.oeecloud/files/app/_python_bundle/modules
04-01 19:48:13.380 21723 21762 I python : set wchar paths...
04-01 19:48:13.420 21723 21762 I python : Initialized python
04-01 19:48:13.420 21723 21762 I python : AND: Init threads
04-01 19:48:13.421 21723 21762 I python : testing python print redirection
04-01 19:48:13.422 21723 21762 I python : Android path ['.', '/data/user/0/org.test.oeecloud/files/app/_python_bundle/stdlib.zip', '/data/user/0/org.test.oeecloud/files/app/...
'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
...
04-01 19:48:16.306 21723 21762 I python : [INFO ] [Base ] Leaving application in progress...
04-01 19:48:16.307 21723 21762 I python : Traceback (most recent call last):
04-01 19:48:16.309 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 97, in <module>
04-01 19:48:16.311 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/app.py", line 855, in run
04-01 19:48:16.312 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 504, in runTouchApp
04-01 19:48:16.312 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 747, in mainloop
04-01 19:48:16.313 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/core/window/window_sdl2.py", line 479, in _mainloop
04-01 19:48:16.314 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/base.py", line 339, in idle
04-01 19:48:16.314 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oeecloud/kivy/clock.py", line 591, in tick
04-01 19:48:16.315 21723 21762 I python : File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
04-01 19:48:16.315 21723 21762 I python : File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
04-01 19:48:16.315 21723 21762 I python : File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
04-01 19:48:16.316 21723 21762 I python : File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
04-01 19:48:16.316 21723 21762 I python : File "/home/julian/kivy/.buildozer/android/app/main.py", line 52, in oee_anzeige
04-01 19:48:16.317 21723 21762 I python : AttributeError: 'NoneType' object has no attribute 'text'
04-01 19:48:16.317 21723 21762 I python : Python for android ended.