[Python] Plyer Filechooser working perfectly on Windows but does not work on Android

Discussão em 'Python' iniciado por Stack, Fevereiro 4, 2025.

  1. Stack

    Stack Membro Participativo

    When I use Plyer filechooser on my kivy app and print the path of the file selected, it works perfectly fine on windows but when I convert it into apk and run on android, it does not work. When I checked the logcat, I found out that 'None' was returned instead of the path> 05-30 10:52:48.198 31664 31664 I python : []

    When I checked the plyer/filechooser.py on github(as there is no proper docs), I came across the following statements: Android runs Activity asynchronously via pausing our PythonActivity and starting a new one in the foreground. This means AndroidFileChooser._open_file() will always return the default value of AndroidFileChooser.selection i.e. None.

    I don't understand what that mean, but I am not able to get the path of the file. Why is it it returning None? I have enabled READ_EXTERNAL_STORAGE on buildozer permissions as well as on my phone.

    How can I solve this issue. I want to create the app as soon as possible. Any help is greatly appreciated.

    My code using filechooser:

    from plyer import tts,filechooser
    ...

    def file_chooser(self):
    filechooser.open_file(on_selection=self.selected)
    def selected(self, filename):
    if not len(filename) == 0:
    print(filename[0])
    self.file = filename[0]


    along with an mdraisedbutton > on_press: app.file_chooser()

    Continue reading...

Compartilhe esta Página