Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Filechooser not working #512

Closed
Sirfanas opened this issue Aug 9, 2019 · 8 comments
Closed

Android Filechooser not working #512

Sirfanas opened this issue Aug 9, 2019 · 8 comments

Comments

@Sirfanas
Copy link

Sirfanas commented Aug 9, 2019

Hi,
I need to get file from my Kivy app
I try the Filechooser code sample example/filechooser of Plyer repo but it's not working on Android:

When I push the "Select a file" button I have my native Android file chooser app, but when I choose a file, it go back to my Kivy screen and in "selected file" field I got [[]]

So I don't have the path to open the file. Have I miss something ?
I did add permission to storage on my app and I add plyer in buildozer requirements

Here the screenshot:
Screenshots

Any ideas ?
Thanks !

EDIT:
Forgot technical info 😄
Kivy: 1.11.1
Plyer: 1.4.0
Python: 3

Android: 9 (But don't seem to be linked cause I reproduce on 8)

@guokaiyi
Copy link

I had the same problem

Android:6/7/8

@Sirfanas
Copy link
Author

Sirfanas commented Nov 6, 2019

No one actually found anything for that ?

@Zen-CODE
Copy link
Member

Zen-CODE commented Jan 2, 2020

It is not enough any more to add the permissions in buildozer: you have to request permission at run-time, or manually add it after installing the app. I had the same problem until requesting permissions, then it worked. @Sirfanas Please test that and post your findings?

Thanks

@Sirfanas
Copy link
Author

Sirfanas commented Jan 8, 2020

@Zen-CODE thank's for the answer, but it's not working for me, maybe I actually did something wrong ?
It did ask me for storage permission, In settings it's checked as allowed, but when I click on a file it didn't work.
Now it actually give me a black screen and in log I have:


01-08 10:28:05.894 29476 29476 I python  :  Traceback (most recent call last):                                                                                                                
01-08 10:28:05.894 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 267, in _handle_downloads_documents                                                                                                                                                            
01-08 10:28:05.895 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 371, in _parse_content                                                                                                                                                                         
01-08 10:28:05.895 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 1044, in jnius.jnius.JavaMultipleMethod.__call__                                                      
01-08 10:28:05.895 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 766, in jnius.jnius.JavaMethod.__call__                                                               
01-08 10:28:05.895 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 843, in jnius.jnius.JavaMethod.call_method                                                            
01-08 10:28:05.895 29476 29476 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception                                                                           
01-08 10:28:05.895 29476 29476 I python  :  jnius.jnius.JavaException: JVM exception occurred: Unknown URI: content://downloads/public_downloads/3475                                         
01-08 10:28:05.907 29476 29476 I python  :  Traceback (most recent call last):                                                                                                                
01-08 10:28:05.907 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 267, in _handle_downloads_documents                                                                                                                                                            
01-08 10:28:05.907 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 365, in _parse_content                                                                                                                                                                         
01-08 10:28:05.907 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 766, in jnius.jnius.JavaMethod.__call__                                                               
01-08 10:28:05.907 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 860, in jnius.jnius.JavaMethod.call_method                                                            
01-08 10:28:05.907 29476 29476 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception                                                                           
01-08 10:28:05.907 29476 29476 I python  :  jnius.jnius.JavaException: JVM exception occurred: UID 10439 does not have permission to content://downloads/all_downloads/3475 [user 0]          
01-08 10:28:05.910 29476 29476 I python  :  Traceback (most recent call last):                                                                                                                
01-08 10:28:05.910 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 288, in _handle_downloads_documents                                                                                                                                                            
01-08 10:28:05.910 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 381, in _parse_content                                                                                                                                                                         
01-08 10:28:05.910 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 1044, in jnius.jnius.JavaMultipleMethod.__call__                                                      
01-08 10:28:05.910 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 766, in jnius.jnius.JavaMethod.__call__                                                               
01-08 10:28:05.910 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 843, in jnius.jnius.JavaMethod.call_method                                                            
01-08 10:28:05.911 29476 29476 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception                                                                           
01-08 10:28:05.911 29476 29476 I python  :  jnius.jnius.JavaException: JVM exception occurred: Unknown URI: content://downloads/public_downloads/3475                                         
01-08 10:28:05.915 29476 29476 I python  :  Traceback (most recent call last):                                                                                                                
01-08 10:28:05.915 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 288, in _handle_downloads_documents                                                                                                                                                            
01-08 10:28:05.915 29476 29476 I python  :    File "/home/user/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/filechooser/plyer/platforms/android/filechooser.py", line 365, in _parse_content                                                                                                                                                                         
01-08 10:28:05.915 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 766, in jnius.jnius.JavaMethod.__call__                                                               
01-08 10:28:05.915 29476 29476 I python  :    File "jnius/jnius_export_class.pxi", line 860, in jnius.jnius.JavaMethod.call_method                                                            
01-08 10:28:05.916 29476 29476 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception                                                                           
01-08 10:28:05.916 29476 29476 I python  :  jnius.jnius.JavaException: JVM exception occurred: UID 10439 does not have permission to content://downloads/all_downloads/3475 [user 0]

Here is my buildozer.spec and main.py (which is copy paste from exemple/filechooser, just add permission request): src.zip

Here's my app permission
81890850_2425775397685825_3671833348839309312_n

Do you have any ideas ?
Tank's

@prawnydagrate
Copy link

I don't think I have any ideas, but thanks for posting src.zip. I looked at your main.py file and learned how to request permissions. Now my app is fixed! Thank you so much!

@Sirfanas
Copy link
Author

I don't think I have any ideas, but thanks for posting src.zip. I looked at your main.py file and learned how to request permissions. Now my app is fixed! Thank you so much!

Well nice to hear this helped you 😅
But the problem is still there 😅
@Zen-CODE do you have any clue or anything ?
I haven't try since last time but the issue is open so I suppose it's not fixed ?

@Zen-CODE
Copy link
Member

@Sirfanas Well, it's not fixed because we can't reproduce it. It works for me, so there is something different in your setup or code. Have you tried requesting runtime permissions? That's android specific, so not in the plyer example...

https://python-for-android.readthedocs.io/en/latest/apis/

@Sirfanas
Copy link
Author

Sirfanas commented Aug 3, 2020

@Sirfanas Well, it's not fixed because we can't reproduce it. It works for me, so there is something different in your setup or code. Have you tried requesting runtime permissions? That's android specific, so not in the plyer example...

https://python-for-android.readthedocs.io/en/latest/apis/

Well, I just try again and I was able to get a filepath, I did well add Permission request in my Python file, but I didn't add it in the buildozer.spec... Maybe this should be explained in the documentation ?

Putting zip with the plyer sample with android permission + my buildozer.spec
Thank's

SRC: android_filechooser.zip

@Sirfanas Sirfanas closed this as completed Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants