Answer the question
In order to leave comments, you need to log in
Socket + Buildozer?
I want to send a UDP packet from the APK of the application, but the bulldozer is against it. If you just silently import socket into the code, it will not work, the application will crash. It is possible to work with HTTP, but not with the protocol?
Here's what I've tried and it doesn't work;
requirements = socket
Compiling with Cython
client.cpython-38.so
Used C language, ran inside python.
I got into kivy.network and wrote an additional library.
I tried scapy.all
Here is a person with the same problem, asked a question on github
https://github.com/kivy/buildozer/issues/1121
Interesting, but you can't import aiohttp either?) Somehow stupidly it turns out that socket cannot be imported into the kivy project .
import socket
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.button import Button
class Send_UDP():
def __init__(self, host='192.168.12.1', port=787):
self.host = host
self. port = port
self.server = (self.host, self.port)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def send(self, packet):
self.sock.sendto(packet.encode( "UTF-8"), self.server)
se=Send_UDP()
class Test(MDApp):
def build(self):
se.send('test packet')
button = Button(text='Hello world', font_size= 14)
return button
Test().run()
Compile: buildozer android debug deploy run
Answer the question
In order to leave comments, you need to log in
I solved the problem! If anyone has bumped into it, here's what to do:
1. requirements = python3,kivy,kivymd
Import ALL python3 modules, including socket. If the module was installed additionally - pip install new_module. Then you need to specify an example - kivymd
2. An error will appear - [Errno 13] Permission denied. And then it dawned on me, you need to remove # android.permissions = INTERNET in buildozer
You need to indicate that your application is needed on the Network, then you can safely use socket
Everything can be deleted from the forum) Thank you all
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question