在 WSL 中使用 buildozer 创建 kivy android 包

creating kivy android package using buildozer in WSL

我正在 Windows 子系统中为 Linux 构建一个 kivy android 包,但我遇到了这个 shutil 错误

shutil.error: [(src,destination, "[Errno 13] Permission denied:destination")]

完整日志为:

(kvenv) root@LAPTOP-IEKPNDEA:/mnt/d/think_dignity_projects/avsar/avsar_androidAPP# buildozer -v android debug
# Check configuration tokens

Buildozer is running as root!
This is not recommended, and may lead to problems later.
Are you sure you want to continue [y/n]? y

# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.7 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /root/anaconda3/envs/kvenv/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool
# Install platform
# Run 'git config --get remote.origin.url'
# Cwd /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/platform/python-for-android
https://github.com/kivy/python-for-android.git
# Run 'git branch -vv'
# Cwd /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/platform/python-for-android
* master 1b3b0e3f [origin/master] Merge pull request #2225 from kivy/release-2020.06.02
# Run '/root/anaconda3/envs/kvenv/bin/python3.8 -m pip install -q  \'appdirs\' \'colorama>=0.3.3\' \'jinja2\' \'six\' \'enum34; python_version<"3.4"\' \'sh>=1.10; sys_platform!="nt"\' \'pep517<0.7.0"\' \'toml\''
# Cwd None
# Apache ANT found at /root/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /root/.buildozer/android/platform/android-sdk
# Recommended android's NDK version by p4a is: 19c
# Android NDK found at /root/.buildozer/android/platform/android-ndk-r19c
# Check application requirements
# Check garden requirements
# Compile platform
# Run '/root/anaconda3/envs/kvenv/bin/python3.8 -m pythonforandroid.toolchain create --dist_name=avsar --bootstrap=sdl2 --requirements=python3,kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21'
# Cwd /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/platform/python-for-android
/mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py:84: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Found Android API target in $ANDROIDAPI: 27
[INFO]:    Available Android APIs are (27)
[INFO]:    Requested API target 27 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK: /root/.buildozer/android/platform/android-ndk-r19c
[INFO]:    Found NDK version 19c
[INFO]:    Getting NDK API version (i.e. minimum supported API) from user argument
[INFO]:    ccache is missing, the build will not be optimized in the future.
[INFO]:    Found the following toolchain versions: ['4.9']
[INFO]:    Picking the latest gcc toolchain, here 4.9
[INFO]:    Of the existing distributions, the following meet the given requirements:
[INFO]:         avsar: min API 21, includes recipes (hostpython3, libffi, openssl, sdl2_image, sdl2_mixer, sdl2_ttf, sqlite3, python3, sdl2, setuptools, six, pyjnius, android, kivy, certifi), built for archs (armeabi-v7a)
[INFO]:    avsar has compatible recipes, using this one
# Build the application #7
# Copy application source from /mnt/d/think_dignity_projects/avsar/avsar_androidAPP
# Create directory /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/app
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/main.kv
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/main.py
# Create directory /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/app/UI_data
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/labour.jpg
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/lady.jpg
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/lady.png
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/lady2.png
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/lady3.jpeg
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/Picture1.jpg
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/WhatsApp Image 2020-06-02 at 2.03.35 PM.jpeg
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/WhatsApp Image 2020-06-02 at 2.03.50 PM.jpeg
# Copy /mnt/d/think_dignity_projects/avsar/avsar_androidAPP/UI_data/WhatsApp Image 2020-06-02 at 2.03.51 PM.jpeg
Traceback (most recent call last):
  File "/root/anaconda3/envs/kvenv/bin/buildozer", line 8, in <module>
    sys.exit(main())
  File "/root/anaconda3/envs/kvenv/lib/python3.8/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/root/anaconda3/envs/kvenv/lib/python3.8/site-packages/buildozer/__init__.py", line 1047, in run_command
    self.target.run_commands(args)
  File "/root/anaconda3/envs/kvenv/lib/python3.8/site-packages/buildozer/target.py", line 92, in run_commands
    func(args)
  File "/root/anaconda3/envs/kvenv/lib/python3.8/site-packages/buildozer/target.py", line 104, in cmd_debug
    self.buildozer.build()
  File "/root/anaconda3/envs/kvenv/lib/python3.8/site-packages/buildozer/__init__.py", line 202, in build
    self.build_application()
  File "/root/anaconda3/envs/kvenv/lib/python3.8/site-packages/buildozer/__init__.py", line 717, in build_application
    self._copy_application_libs()
  File "/root/anaconda3/envs/kvenv/lib/python3.8/site-packages/buildozer/__init__.py", line 817, in _copy_application_libs
    copytree(self.applibs_dir, join(self.app_dir, '_applibs'))
  File "/root/anaconda3/envs/kvenv/lib/python3.8/shutil.py", line 554, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
  File "/root/anaconda3/envs/kvenv/lib/python3.8/shutil.py", line 510, in _copytree
    raise Error(errors)
shutil.Error: [('/mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/applibs', '/mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/app/_applibs', "[Errno 13] Permission denied: '/mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/app/_applibs'")]

当我打开目录“/mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/android/app/_applibs”和“/mnt/d/think_dignity_projects/avsar/avsar_androidAPP/.buildozer/applibs”时,它们都是空的

问题已解决。

我只需要 运行 buildozer 作为 root。就这些了。

只需进入 .buildozer 文件夹 属性 并授予所有用户所有权限(完全访问权限)并应用它们并再次尝试 运行 命令 (我在 Ubuntu 软件中使用 windows 系统) 只需为所有用户授予对 .buildozer 文件夹的填充访问权限