shutil: copytree error: "[Errno 13] Permission denied" on Android

321 views
Skip to first unread message

Henrik R.

unread,
Aug 19, 2024, 3:28:46 PM8/19/24
to Kivy users support
This is an error that does not make my app crash, but it's not very confidence-inspiring to see it every time I look at the log output from my Android v.8.1.0 phone. There are 10 "[Errno 13] Permission denied" errors:

python  : Run user program, change dir and execute entrypoint
python  : [ERROR  ] Error when copying logo directory
python  : Traceback (most recent call last):
python  :   File "/mnt/4AF15A0435E762B4/mypython/GeoESP-android/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/python-installs/geoesptraining/armeabi-v7a/kivy/__init__.py", line 372, in <module>
python  :   File "/mnt/4AF15A0435E762B4/mypython/GeoESP-android/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Lib/shutil.py", line 561, in copytree
python  :   File "/mnt/4AF15A0435E762B4/mypython/GeoESP-android/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Lib/shutil.py", line 515, in _copytree
python  : shutil.Error: [('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-128.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-128.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-128.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-16.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-16.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-16.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-24.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-24.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-24.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-256.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-256.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-256.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-32.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-32.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-32.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-48.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-48.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-48.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-512.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-512.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-512.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-64.ico', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-64.ico', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-64.ico'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-64.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-64.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-64.png'"), ('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon'")]
python  : [WARNING] [Config      ] Older configuration version detected (0 instead of 27)
python  : [WARNING] [Config      ] Upgrading configuration in progress.
python  : [DEBUG  ] [Config      ] Upgrading from 0 to 1

Is there anything to do about it?

I can add these log lines:

[Kivy        ] v2.3.0
[Python      ] v3.11.5 (main, Aug  7 2024, 13:25:42) [Clang 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0

ELLIOT GARBUS

unread,
Aug 19, 2024, 3:43:38 PM8/19/24
to Kivy users support


From: kivy-...@googlegroups.com <kivy-...@googlegroups.com> on behalf of Henrik R. <henrik.r...@gmail.com>
Sent: Monday, August 19, 2024 12:28 PM
To: Kivy users support <kivy-...@googlegroups.com>
Subject: [kivy-users] shutil: copytree error: "[Errno 13] Permission denied" on Android
 
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/0cb31b76-8b06-4926-bb00-21f19f6d26bbn%40googlegroups.com.

Henrik R.

unread,
Aug 27, 2024, 2:17:04 PM8/27/24
to Kivy users support
Thank you.
I have (more or less) read that document. But the shutil copy operation is an internal Kivy 'thing', so I cannot really see how I could have any influence on it? I presume it is something the Kivy developers would have to deal with - if they find it sufficiently important. :-)
So I guess I should report it as a Kivy issue - although nobody seems to have done anything about the 3 issues I have reported in the last 2 weeks... :-( which is a bit worrying... Is Kivy a dying project? Or is it because everybody are occupied with Kivy 3.0?

ELLIOT GARBUS

unread,
Aug 27, 2024, 5:57:43 PM8/27/24
to Kivy users support
I have not done any programming on Android, when I look at those error messages, I suspect an issue with permissions on storage, or a problem with file paths.

Sent: Tuesday, August 27, 2024 11:17 AM

To: Kivy users support <kivy-...@googlegroups.com>
Subject: Re: [kivy-users] shutil: copytree error: "[Errno 13] Permission denied" on Android
 

Tomek CEDRO

unread,
Aug 27, 2024, 6:42:05 PM8/27/24
to kivy-...@googlegroups.com
1. Use resource_add_path('myapp/assets/fonts') so files are available
by filename, or just name like in case of fonts. No need to provide
full path just relative path in your application.

2. If you want to store local application files use
`app.user_data_dir` provided location kivy will auto-select best place
depending on where application runs on (i.e. home directory
`~/.config/appname` in unix desktop, valid storage location on a
mobile device that is hard to guess because these differ among
different androids lol). Then you can f'{app.user_data_dir}/somefile'
to read/write local files. Do not hardcode your own full paths.

3. Make sure these files program wants to access are there - you can
use device explorer to view all files on android emulator it can be
accesses from Android Studio / ACD Manager. You cannot browse that
easily a physical device if its not rooted. Maybe application tries to
access files that are not there?

4. If you use Buildozer review the configuration settings maybe
something is wrongly hardcoded over there?

Hope that helps :-)
Tomek
> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CH3PR10MB7187B2B7C2724DC9C3EF3B32A3942%40CH3PR10MB7187.namprd10.prod.outlook.com.



--
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info

Henrik R.

unread,
Aug 28, 2024, 5:51:15 AM8/28/24
to Kivy users support
OK. Thank you for your answers. But maybe I wasn't expressing myself clearly enough.
All these files have names like this "kivy-icon-*.png". I have nothing to do with them. My app does not work with any of these files, so I have no influence on how and where they are stored or copied.
Therefore I regard this as a Kivy issue that should be posted on https://github.com/kivy/kivy/issues/

Tomek CEDRO

unread,
Aug 28, 2024, 1:16:31 PM8/28/24
to kivy-...@googlegroups.com
Can you check point 3 too? Verify files presence both on deployment
device and build machine locations? If files are there can you ls -al
?

Can you check 4 too? How to you build the mobile application? No
hardcodes over there?

I use buildozer and do not have those messages.. but on newer Android
release.. and lots of things change between each Android release :\

Tomek
> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/77fdbd62-add0-4d17-90c8-6d6e619946c5n%40googlegroups.com.

Henrik R.

unread,
Aug 28, 2024, 2:58:15 PM8/28/24
to Kivy users support
What I can do is to tell you that ONE of these files - kivy-icon-128.png - can be found in the follwoing 9 places, seen from the app-folder, where buildozer.spec, main.py etc. is situated:

.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/other_builds/kivy/arm64-v8a__ndk_target_21/kivy/build/lib.linux-x86_64-3.11/kivy/data/logo/kivy-icon-128.png
.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/other_builds/kivy/arm64-v8a__ndk_target_21/kivy/kivy/data/logo/kivy-icon-128.png
.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/other_builds/kivy/armeabi-v7a__ndk_target_21/kivy/build/lib.linux-x86_64-3.11/kivy/data/logo/kivy-icon-128.png
.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/other_builds/kivy/armeabi-v7a__ndk_target_21/kivy/kivy/data/logo/kivy-icon-128.png
.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/python-installs/geoesptraining/arm64-v8a/kivy/data/logo/kivy-icon-128.png
.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/python-installs/geoesptraining/armeabi-v7a/kivy/data/logo/kivy-icon-128.png
.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/dists/geoesptraining/_python_bundle__arm64-v8a/_python_bundle/site-packages/kivy/data/logo/kivy-icon-128.png
.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/dists/geoesptraining/_python_bundle__armeabi-v7a/_python_bundle/site-packages/kivy/data/logo/kivy-icon-128.png
newvenv/lib/python3.8/site-packages/kivy/data/logo/kivy-icon-128.png

If you want to see the buildozer.spec, I have attached it here:
buildozer.spec

Tomek CEDRO

unread,
Aug 28, 2024, 3:32:02 PM8/28/24
to kivy-...@googlegroups.com
In the buildozer.spec icon.filename variable is not set, kivy seems to
try searching for a default icon but that fails, its not really a
permission problem but existentional problem :-)

Try setting the icon in buildozer.spec and see if that helps:

icon.filename = %(source.dir)s/location/of/your/icon.png


When analyzing problems on Android it is good to work with AVD + file
explorer from Android Studio because that allows you to browse
everything on the AVD what is not possible on a physical production
device. If you analyze problem with Android application you should
browse files on the device not the intermediate build host files.

Standard unix / posix shell utility "find" is also your friend when
you want to find / modify some files. You can also use it directly on
android adb shell.

For instance this will search for icon files and list attributes of files found:

find . -iname "kivy-icon*.png" -ls

You can also execute commands on every file found (filename is denoted
"{}" here, end of command is denoted "\;"):

find . -iname "kivy-icon*.png" -exec ls -al {} \;

man find for more details :-)

Hope that helps :-)
Tomek




> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/b6c0ad1d-8f06-4965-a2d8-3bce5e5054fbn%40googlegroups.com.

Henrik R.

unread,
Aug 28, 2024, 4:16:34 PM8/28/24
to Kivy users support
You write "location/of/your/icon.png".
Don't you understand that I DON'T HAVE any icons!
I don't know anything about what the "kivy-icon-*.png" files are! Although I can guess that they are icons created by the Kivy system...

Tomek CEDRO

unread,
Aug 28, 2024, 4:46:52 PM8/28/24
to kivy-...@googlegroups.com
Yes this may be a bug in kivy or buildozer or p4a, or your
buildozer.spec configuration problem. I suspect the second because I
do not see this kind of problem on my build environment.

Maybe you just need to create your own icon for your application put
it along the sources and declare it in buildozer.spec and the problem
will be gone, please try that so we know if this is cause of the
problem or not.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3fe603cd-8eb2-4431-8d48-5e019fabb15fn%40googlegroups.com.

Henrik R.

unread,
Aug 29, 2024, 11:02:37 AM8/29/24
to Kivy users support
OK. I can try editing the buildozer.spec, to point to an icon, but what is the meaning of the 's' in:

icon.filename = %(source.dir)s/data/icon.png

Tomek CEDRO

unread,
Aug 29, 2024, 11:09:20 AM8/29/24
to kivy-...@googlegroups.com
Its the %(source.dirs)s kind of of inline casting to a string type -
in short words "put content of source.dirs variable defined above and
make it a string" :-)

https://docs.python.org/3/library/string.html
> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/aa6374e7-809f-4141-9e38-7205c2cbc8d3n%40googlegroups.com.

Henrik R.

unread,
Aug 29, 2024, 12:39:47 PM8/29/24
to Kivy users support
OK. So I inserted this line in buildozer.spec:

icon.filename = %(source.dir)s/logo/kivy-icon-512.png

But I still have all the [Errno 13] Permission denied errors, including this:

('/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/data/logo/kivy-icon-512.png', '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-512.png', "[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-512.png'")

But if someone solves the issues in the Kivy install instructions I have filed - https://github.com/kivy/kivy/issues/8803 - and - https://github.com/kivy/kivy/issues/8804 - then I can install KIvy and Buildozer on my new Linux Mint 22 partition and see if there is the same problem there.

Tomek CEDRO

unread,
Aug 31, 2024, 7:30:12 AM8/31/24
to kivy-...@googlegroups.com
You did create the png icon file and put at location pointing by the
variable right?
> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6a4c98ad-4f66-43ee-af73-9af4eef5f92en%40googlegroups.com.

Henrik R.

unread,
Aug 31, 2024, 8:57:26 AM8/31/24
to Kivy users support
I copied all the kivy-icon-*.png into the %(source.dir)s/logo/ folder.

Tomek CEDRO

unread,
Aug 31, 2024, 9:15:30 AM8/31/24
to kivy-...@googlegroups.com
Thanks :-) We have a proof it may be a bug :-)
> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6627753f-6472-4d60-9ef5-fe9526b71802n%40googlegroups.com.

Henrik R.

unread,
Sep 8, 2024, 6:46:13 AM9/8/24
to Kivy users support
Will you report the issue on Github?
Noone seems to care, when I report bugs there...

ElliotG

unread,
Sep 8, 2024, 11:36:06 AM9/8/24
to Kivy users support
You might want to ask in the Android section of the kivy discord.

Henrik R.

unread,
Oct 12, 2024, 5:02:50 AM10/12/24
to Kivy users support
I can add, that creating a new Linux Mint 21.3 partition, installing Kivy and Buildozer, cloning the app-folder and compiling and deploying my app from there to my new MOTO G24 android phone does not change anything. I still have 10 shutil.Error - _copytree - errors like this:

"[Errno 13] Permission denied: '/data/user/0/dk.transformation.geoesptraining/files/app/.kivy/icon/kivy-icon-128.png'"

Reply all
Reply to author
Forward
0 new messages