Python

The code under android on python kivy does not compile?

I use the basic code in python kivy:

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
 
class MainApp(App):
    def build(self):
        self.operators = ["/", "*", "+", "-"]
        self.last_was_operator = None
        self.last_button = None
        main_layout = BoxLayout(orientation="vertical")
        self.solution = TextInput(
            multiline=False, readonly=True, halign="right", font_size=55
        )
        main_layout.add_widget(self.solution)
        buttons = [
            ["7", "8", "9", "/"],
            ["4", "5", "6", "*"],
            ["1", "2", "3", "-"],
            [".", "0", "C", "+"],
        ]
        for row in buttons:
            h_layout = BoxLayout()
            for label in row:
                button = Button(
                    text=label,
                    pos_hint={"center_x": 0.5, "center_y": 0.5},
                )
                button.bind(on_press=self.on_button_press)
                h_layout.add_widget(button)
            main_layout.add_widget(h_layout)
 
        equals_button = Button(
            text="=", pos_hint={"center_x": 0.5, "center_y": 0.5}
        )
        equals_button.bind(on_press=self.on_solution)
        main_layout.add_widget(equals_button)
 
        return main_layout
 
    def on_button_press(self, instance):
        current = self.solution.text
        button_text = instance.text
 
        if button_text == "C":
            # Очистка виджета с решением
            self.solution.text = ""
        else:
            if current and (
                self.last_was_operator and button_text in self.operators):
                # Не добавляйте два оператора подряд, рядом друг с другом
                return
            elif current == "" and button_text in self.operators:
                # Первый символ не может быть оператором
                return
            else:
                new_text = current + button_text
                self.solution.text = new_text
        self.last_button = button_text
        self.last_was_operator = self.last_button in self.operators
 
    def on_solution(self, instance):
        text = self.solution.text
        if text:
            solution = str(eval(self.solution.text))
            self.solution.text = solution
 
 
if __name__ == "__main__":
    app = MainApp()
    app.run()

When I try to compile the code for Android, I get an error:
Traceback (most recent call last):
  File "/usr/local/bin/buildozer", line 9, in <module>
    load_entry_point('buildozer==0.27', 'console_scripts', 'buildozer')()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 980, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 85, in run_commands
    func(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 95, in cmd_debug
    self.buildozer.prepare_for_build()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 161, in prepare_for_build
    self.target.install_platform()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 424, in install_platform
    self._install_android_packages()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 383, in _install_android_packages
    ver = self._find_latest_package(packages, 'build-tools-')
  File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 349, in _find_latest_package
    version = self._process_version_string(version_string)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 318, in _process_version_string
    version = [int(i) for i in version_string.split(".")]
ValueError: invalid literal for int() with base 10: '0-preview'

The code itself on windows 10 works fine: 5eaec71288ee5917013621.png
5eaec738720cb385405534.png
How can I correctly compile the code for android so that there is no error?
I'm using the Linux image from the developers kivy-buildozer. I'm running on a virtual box.
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Surv16893, 2020-05-03
@Surv16893

check build.spec

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question