import kivy
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.progressbar import ProgressBar
from kivy.uix.image import Image
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import ObjectProperty
from kivy.utils import platform
from android.runnable import run_on_ui_thread
from jnius import autoclass
import os
import random

class TrackButton(ButtonBehavior, FloatLayout):
    track_name = ObjectProperty(None)

class MusicPlayerApp(App):
    def build(self):
        box = BoxLayout(orientation='vertical')
        top_panel = BoxLayout(size_hint=(1, .1))
        title_label = Label(text='Музыкальный плеер', size_hint=(.8, 1))
        progress_bar = ProgressBar(max=100, size_hint=(.6, 1))
        settings_btn = Button(text='Настройки', size_hint=(.2, 1))
        exit_btn = Button(text='Выход', size_hint=(.2, 1))
        top_panel.add_widget(title_label)
        top_panel.add_widget(progress_bar)
        top_panel.add_widget(settings_btn)
        top_panel.add_widget(exit_btn)
        playlist_panel = BoxLayout(size_hint=(1, .6))
        playlist_bg = Image(source='backgr.png', allow_stretch=True, keep_ratio=False)
        if platform == 'android':
            self.media_scanner = autoclass('android.media.MediaScannerConnection')
            self.MediaScannerConnectionClient = autoclass('android.media.MediaScannerConnection$MediaScannerConnectionClient')
            self.client = self.MediaScannerConnectionClient()
            self.conn = self.media_scanner.newMediaScannerConnection(
                kivy.activity._activity.getApplicationContext(), self.client)
            self.conn.connect()
        playlist = BoxLayout(orientation='vertical', size_hint=(1, .8))
        for file in self.get_audio_files():
            track_btn = TrackButton(track_name=file)
            playlist.add_widget(track_btn)
        playlist_controls = BoxLayout(size_hint=(1, .2))
        shuffle_btn = Button(text='Перемешать', size_hint=(.2, 1))
        shuffle_btn.bind(on_press=self.shuffle)
        playlist_controls.add_widget(shuffle_btn)
        playlist_panel.add_widget(playlist_bg)
        playlist_panel.add_widget(playlist)
        bottom_panel = BoxLayout(size_hint=(1, .3))
        bottom_bg = Image(source='backgr.png', allow_stretch=True, keep_ratio=False)
        prev_btn = Button(background_normal='ext.png', size_hint_x=0.2)
        play_btn = Button(background_normal='pl.png', size_hint_x=0.2)
        stop_btn = Button(background_normal='stop.png', size_hint_x=0.2)
        next_btn = Button(background_normal='next.png', size_hint_x=0.2)
        bottom_panel.add_widget(bottom_bg)
        bottom_panel.add_widget(prev_btn)
        bottom_panel.add_widget(play_btn)
        bottom_panel.add_widget(stop_btn)
        bottom_panel.add_widget(next_btn)
        box.add_widget(top_panel)
        box.add_widget(playlist_panel)
        box.add_widget(playlist_controls)
        box.add_widget(bottom_panel)
        return box
def on_pause(self):
        return True
      
    def on_resume(self):
        return True
      
    @run_on_ui_thread
    def on_media_scanner_connected(self):
        self.conn.scanFile(kivy.storagepath.get_home_dir(), None)
      
    def get_audio_files(self):
        if platform == 'android':
            audio_files = []
            while True:
                try:
                    media = self.client.queue.get(timeout=1)
                except:
                    break
                else:
                    file_path = str(media.getPath())
                    file_name = os.path.basename(file_path)
                    if file_name.endswith('.mp3') or file_name.endswith('.m4a') or file_name.endswith('.ogg'):
                        audio_files.append(file_name)
            return audio_files
        else:
            if 'Music' in os.listdir(os.path.expanduser('~')):
                music_dir = os.path.join(os.path.expanduser('~'), 'Music')
            else:
                music_dir = os.path.expanduser('~')
            audio_files = [f for f in os.listdir(music_dir) if f.endswith('.mp3') or f.endswith('.m4a') or f.endswith('.ogg')]
            return audio_files

    def shuffle(self, instance):     
        playlist = self.root.children[1].children[1]
        tracks = playlist.children
        random.shuffle(tracks)
        for track in tracks:
            playlist.remove_widget(track)
            playlist.add_widget(track)

if __name__ == '__main__':
    MusicPlayerApp().run()

исправь код, чтоб он запускался на андроид пайдроид, и допиши к немуbildozer.spec и поясни как собрать апк в пайдроид