Gradle crashing when adding WRITE_EXTERNAL_STORAGE to android.permissions in buildozer.spec

111 views
Skip to first unread message

Hugo Cezar

unread,
Jan 12, 2023, 11:13:02 PM1/12/23
to Kivy users support
When adding additional permissions in buildozer.spec the compilation fails and I get the following error:


tetete.png

By removing WRITE_EXTERNAL_STORAGE from buildozer.spec the build completes but I need the storage permissions. Can someone help me?

Hugo Cezar

unread,
Jan 13, 2023, 12:01:41 AM1/13/23
to Kivy users support

I resolved the issue by deleting a supposedly duplicate line from AndroidManifest.tmpl.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>

But even though the build is working with the storage permission, I'm getting another error when saving a file in the Downloads folder:

PermissionError: [Errno 13] Permission denied: '/storage/emulated/0/Download/teste.txt'

Even accepting the processing I'm getting this error. Someone help me please

Robert

unread,
Jan 13, 2023, 12:04:09 AM1/13/23
to Kivy users support
I was writing as you posted the second part, both issues addressed (sort of):

WRITE_EXTERNAL_STORAGE has no meaning for api >=29  , so there may be more than one issue here:

1) p4a adds WRITE_EXTERNAL_STORAGE for api<29  so that is the cause of the duplicate WRITE_EXTERNAL_STORAGE
Just remove yours

2) > but I need the storage permissions

Back to WRITE_EXTERNAL_STORAGE meaning, Android storage changed with api 29 , 

and p4a now defaults to 31, and 33 is current.  
I assume you are using api 27, there may be an issue running on Android 10+ and the PlayStore certainly won't accept anything less than 31.
But if it works for you you are probably OK for a while.

3) Unrelated, building on the Windows partition can cause strange issues with some packages

Robert

unread,
Jan 13, 2023, 12:20:10 AM1/13/23
to Kivy users support
I see there is an extra potential issue (and this may depend on device Android version, but its not portable design)
See para 3    https://github.com/Android-for-Python/Android-for-Python-Users#storage-permissions

Hugo Cezar

unread,
Jan 13, 2023, 11:19:45 AM1/13/23
to Kivy users support
Hello Roberto, thank you for your attention and for your time. I'm using the android's api 31 but from what I understand, I won't be able to write files in the shared storage of the android, only in the private storage that is the directory of my application, with this information I did a test by creating a file in the installation directory of my application and I get something strange in logcat:

logcat.png

I researched about this error and it's something about the logcat buffer, I didn't quite understand.

I confess that using private storage will not solve my problem, I need other applications to see the file, I need to use shared storage. I will continue reading the documents you sent me. Thank you very much.

Yes, I'm using Windows WSL to build my application, I saw that this could mess up the compilation, so I decided to put my project files in the WSL root folder /home/user/myproject, but that didn't solve my problem also it kept denying permission from file write, but it must be because of API and android version 10.

Hugo Cezar

unread,
Jan 13, 2023, 11:36:47 AM1/13/23
to Kivy users support
Thank you.

Robert

unread,
Jan 13, 2023, 12:08:55 PM1/13/23
to Kivy users support
You will find it is possible to copy files to and from shared storage.

Sorry I don't know what those messages are.

Hugo Cezar

unread,
Jan 13, 2023, 12:14:01 PM1/13/23
to Kivy users support
Yep, one of the solutions is to use androidstorage4kivy library, this is really working. Thank you very much :D

Robert

unread,
Jan 13, 2023, 4:25:26 PM1/13/23
to Kivy users support
:)
Reply all
Reply to author
Forward
0 new messages