-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App crash at startup #1184
Comments
Without details about the crash and steps to reproduce the problem, it will be difficult for anyone to provide any help. |
it seems that at the startup Android gives out this message: ModuleNotFoundError: No module named 'async_timeout' The result is that the app remain in backgrod and doesn't start. Please find the following info:
- main.py import asyncio
import os
from kivymd.app import MDApp
from kivy.lang import Builder
import bleak
KV = """
Screen:
GridLayout:
rows:2
ScrollView:
MDLabel:
id:mdlab
size_hint_y: None
text: "Attesa per scansione BLE"
height: self.texture_size[1]
MDRaisedButton:
id:mdbut
text: "premi per scansione BLE"
size_hint_x:1
on_press: app.premuto_bottone()
"""
class MainApp(MDApp):
event = asyncio.Event()
def build(self):
self.title = "Antibrina"
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Red"
self.theme_cls.primary_hue = "400"
return Builder.load_string(KV)
async def avvia_scansione(self):
devices = await bleak.BleakScanner.discover(1)
if len(devices) == 0:
self.root.ids["mdlab"].text = "No Device Found!"
stringa = ""
for d in devices:
stringa += d.address + " " + str(d.rssi)
if d.name != None :
stringa += " " + d.name
stringa += "\n"
self.root.ids["mdlab"].text = stringa
def premuto_bottone(self):
self.root.ids["mdlab"].text = "Scanning for 5 seconds...."
if os.environ.get("P4A_BOOTSTRAP") is not None:
self.root.ids["mdlab"].text = "Android Ok !"
else:
self.root.ids["mdlab"].text = "Android KO !"
asyncio.create_task(self.avvia_scansione())
app = MainApp()
async def main(app):
await app.async_run("asyncio")
asyncio.run(main(app)) |
This is a 3rd-party module and likely needs to be added to some depedency list somewhere. Maybe here?
|
Maybe, but the Android Log Stream write that there is the following import error: "/home/ronni/app/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/bleak/init.py", line 31, in at the line 31 of the file init.py , there is the followinfg code: sys.version_info < (3, 11): it seems that the script recognize a python version older that 3.11 and so it import the timeout library drom the external async_timeout package instead of from the asyncio . I think that Android doesn't find the "async_timeout" lib to import. On the contrary, on Windows, where the this library is installed as dependecy of the bleak package, the python finds the lib to import. do I have to declare something special inside my buildozer.spec file ? |
I don't know much about how buildozer works. The line of code I linked to above was my best guess of where something needs to be changed. |
I solver the problem adding "async-timeout" in the requirements( the lib name was different from label "async_timeout" used in the import declaration ...) Now the app starts, but when I try to scan for ble devices, i give back an exception. It desn'pt find the class "com.github.hbldh.bleak.PythonScanCallback
Can you help me ? Of course it works On windows. |
Can you make a pull request to fix this?
Sounds like #756 |
Sounds Good ! I've included the java files in the buildozer.spec, using the keywords "android.add_src" and it works for the moment, I've tested only the scan function of the library. is it possible to make some change to load the java files automatically ?? |
If someone else is facing a similar issue with the example app. Along with these fixes mentioned (This issue and #756). Specify your python3 version in requirements eg. python3==3.10.6 |
I had similar problems with the example app. With those fixes, mentioned above, i was able to run it. But i have a different problem now: The app has no permissions to access the BLE Module of the phone i think. I already tried different fixes but im not able to fix it. This is the error log from the phone: Im new to coding so im sorry if i missed important information you may need to help. |
It's August 2023 and brinata's solution of adding async-timeout to the requirements line in buildozer still worked for me. |
if I insert the following line in my Android App:
"import bleak"
the app crashes at start up in my mobile, but it works under windows 10.
On windows I'm using the following versions:
Pythpn 3.10.9
bleak 0.19.5
Kivy 2.1.0
buildozer 1.4.0
Inside the builddozer.spec file I haven't specify the version of the packages
Can Someone Help me ?
The text was updated successfully, but these errors were encountered: