Building App doesnt work

Joined
Jan 15, 2023
Messages
1
Reaction score
0
so ive been trying to build my first mobile app. Im pretty new to programming so my code probably doesnt look so great but it is working on my pc. however when i tried to compile it for android it just didnt wanna work and im completely helpless. i followed a tutorial and tried to compile with buildozer. however the first run took around 2hours until it crashed. i tried it again and after 1 hour and a few warnings it finally made an apk, which.... doesnt work. the apk is 27mb and the folder is !!! 4GB !! with 8000 folders in it and 70.000 files and my app is just a simply gui for translation. if anyone could help me it would be awesome.



Pythoncode:


from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import StringProperty
import requests
import pyttsx3

#button_pressed: 1=Ausgangssprache DE 2=Ausgangssprache EN 3=Zielsprache DE 4=Zielsprache EN 5=Übersetzen 6=Vorlesen 7=reset textfeld

def translate_text(eingabe_text, source_lang, target_lang):
url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl={}&tl={}&dt=t&q={}".format(source_lang, target_lang, eingabe_text)
res = requests.get(url)
return res.json()[0][0][0]

class MainWindow(Screen):
Ausgangssprache=""
Zielsprache=""
label_text1=StringProperty()
label_text2=StringProperty()
def button_pressed5(self):
eingabe_text = self.ids.eingabe_texte
eingabe_text2=eingabe_text.text
if eingabe_text2 and self.Ausgangssprache and self.Zielsprache:
source_lang=self.Ausgangssprache
target_lang=self.Zielsprache
translated_text=translate_text(eingabe_text2, source_lang, target_lang)
self.manager.get_screen('main').label_text2 = translated_text
self.manager.get_screen('main').label_text1 = eingabe_text2
else:
pass


def button_pressed6(self):
eingabe_text = self.ids.eingabe_texte
eingabe_text2=eingabe_text.text
if eingabe_text2 and self.Ausgangssprache and self.Zielsprache:
source_lang=self.Ausgangssprache
target_lang=self.Zielsprache
translated_text=translate_text(eingabe_text2, source_lang, target_lang)
self.manager.get_screen('main').label_text2 = translated_text
self.manager.get_screen('main').label_text1 = eingabe_text2
if target_lang=="en":
x=1 #englische Stimme
elif target_lang=="de":
x=0 #deutsche Stimme
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[x].id)
# Set the volume and rate of the speech
engine.setProperty('volume', 1)
engine.setProperty('rate', 150)

# Speak the text
engine.say(translated_text)

# Play the speech
engine.runAndWait()
else:
pass
def button_pressed7(self):
self.ids.eingabe_texte.text = ""

pass

class SprachWindow1(Screen):
def button_pressed1(self):
self.manager.get_screen('main').label_text1 = "Ausgangssprache: Deutsch"
self.manager.get_screen('main').Ausgangssprache = "de"

def button_pressed2(self):
self.manager.get_screen('main').label_text1 = "Ausgangssprache: Englisch"
self.manager.get_screen('main').Ausgangssprache = "en"

pass
class SprachWindow2(Screen):
def button_pressed3(self):
self.manager.get_screen('main').label_text2 = "Zielsprache: Deutsch"
self.manager.get_screen('main').Zielsprache = "de"

def button_pressed4(self):
self.manager.get_screen('main').label_text2 = "Zielsprache: Englisch"
self.manager.get_screen('main').Zielsprache = "en"

pass
class WindowManager(ScreenManager):
pass

kv = Builder.load_file("ubersetzer.kv")

class Übersetzer(App):


def build(self):

return kv


if __name__ == '__main__':
Übersetzer().run()


.kv file:






WindowManager:
MainWindow:
SprachWindow1:
SprachWindow2:

<MainWindow>:
name: "main"
FloatLayout:
TextInput:
id:eingabe_texte
pos_hint: {"x": 0, "top": 1}
size_hint: 0.8, 0.2
Button:
text:"Reset"
pos_hint: {"x": 0.8 , "top": 1}
size_hint: 0.2,0.2
on_release:
root.button_pressed7()

Label:
pos_hint: {"x": 0, "top": 0.8}
size_hint: 0.5, 0.2
text: root.label_text1
color: 0,0,0,1
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
Label:
pos_hint: {"x": 0.5, "top": 0.8}
size_hint: 0.5, 0.2
text: root.label_text2
color: 0,0,0,1
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
Button:
pos_hint: {"x": 0, "top": 0.6}
size_hint: 0.5, 0.3
text: "Ausgangssprache"
on_release:
app.root.current = "second"
root.manager.transition.direction = "left"

Button:
pos_hint: {"x": 0.5, "top": 0.6}
size_hint: 0.5, 0.3
text: "Zielsprache"
on_release:
app.root.current = "third"
root.manager.transition.direction = "left"
Button:
pos_hint: {"x": 0, "top": 0.3}
size_hint: 0.5, 0.3
text: "Übersetzen"
on_release:
root.button_pressed5()
Button:

pos_hint: {"x": 0.5, "top": 0.3}
size_hint: 0.5, 0.3
text: "Vorlesen"
on_release:
root.button_pressed6()
<SprachWindow1>:

name: "second"

FloatLayout:
Button:

pos_hint: {"x": 0, "top": 1}
size_hint: 1, 0.5
text: "Deutsch"
on_release:
root.button_pressed1()
app.root.current = "main"
root.manager.transition.direction = "right"


Button:
pos_hint: {"x": 0, "top": 0.5}
size_hint: 1, 0.5
text: "Englisch"
on_release:
root.button_pressed2()
app.root.current = "main"
root.manager.transition.direction = "right"
<SprachWindow2>:
name: "third"
FloatLayout:
Button:
pos_hint: {"x": 0, "top": 1}
size_hint: 1, 0.5
text: "Deutsch"
on_release:
root.button_pressed3()
app.root.current = "main"
root.manager.transition.direction = "right"
Button:
pos_hint: {"x": 0, "top": 0.5}
size_hint: 1, 0.5
text: "Englisch"
on_release:
root.button_pressed4()
app.root.current = "main"
root.manager.transition.direction = "right"


















if __name__ == '__main__':
Übersetzer().run()
 
Joined
Jan 30, 2023
Messages
108
Reaction score
13
It sounds like you have run into an issue with building an APK from your Python code using Buildozer. To reduce the size of the APK, you can try excluding unnecessary dependencies, reducing the size of any included assets, and considering using a more lightweight GUI framework.

Here are some steps to help you with building an APK with Buildozer:

  1. Edit your buildozer.spec file: a. Set log_level = 2 to show more verbose output during the build process. b. Remove any unnecessary dependencies. c. Reduce the size of any included assets.
  2. Re-run Buildozer with the buildozer android debug command.
  3. If the APK still does not work, check the output from Buildozer for any error messages or warnings.
  4. If the APK size is still too large, consider using a more lightweight GUI framework or look into optimizing your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,707
Messages
2,569,343
Members
44,635
Latest member
Matt231

Latest Threads

Top