buildozer: Buildozer Error `ValueError: read of closed file`

Versions

  • Python: 3.7.1
  • OS: ArchLinux 4.19.4-arch1-1-ARCH
  • Kivy: 1.10.1
  • Cython: 0.29.1

Description

I compile my project “Hello world” and catch the error on the program Buildozer

buildozer.spec

buildozer.txt

Logs

# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Install platform
# Apache ANT found at /home/deax/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/deax/.buildozer/android/platform/android-sdk-20
# Android NDK is missing, downloading
Traceback (most recent call last):
  File "/usr/bin/buildozer", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.7/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/lib/python3.7/site-packages/buildozer/__init__.py", line 1059, in run_command
    self.target.run_commands(args)
  File "/usr/lib/python3.7/site-packages/buildozer/target.py", line 92, in run_commands
    func(args)
  File "/usr/lib/python3.7/site-packages/buildozer/target.py", line 102, in cmd_debug
    self.buildozer.prepare_for_build()
  File "/usr/lib/python3.7/site-packages/buildozer/__init__.py", line 176, in prepare_for_build
    self.target.install_platform()
  File "/usr/lib/python3.7/site-packages/buildozer/targets/android.py", line 507, in install_platform
    self._install_android_ndk()
  File "/usr/lib/python3.7/site-packages/buildozer/targets/android.py", line 319, in _install_android_ndk
    cwd=self.buildozer.global_platform_dir)
  File "/usr/lib/python3.7/site-packages/buildozer/__init__.py", line 687, in download
    urlretrieve(url, filename, report_hook)
  File "/usr/lib/python3.7/urllib/request.py", line 1817, in retrieve
    block = fp.read(bs)
  File "/usr/lib/python3.7/tempfile.py", line 481, in func_wrapper
    return func(*args, **kwargs)
ValueError: read of closed file

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Looks like the NDK download URL has been a bit of a moving target.

two ways I was able to resolve this:

option 1) to get buildozer to perform the download for you by correcting the download URL: <PYTHON_INSTALL_DIR>/site_packages/buildozer/targets/android.py line 316 change the url from /repository/ to /ndk/ then rerun buildozer as normal and it detects that the NDK is missing and downloads it from the correct URL.

option 2) do the download by hand per codingsett’s comment, but make sure you have the version that buildozer expects. In my case it wants r9c. So download http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2, and unzip it into the expected location, in this case ~/.buildozer/android/platform then run buildozer again as normal.

clear old buildozer files $rm -rf .buildozer uninstall latest version $pip uninstall buildozer cython install old stable version $pip install buildozer==0.34, cython==0.25.2 initialize buildozer and sdk $buildozer init && buildozer android adb -- version again remove .buildozer and upgrade to latest version $rm -rf .buildozer $pip install buildozer==0.37, cython==0.28.5 --upgrade use

Download ndk manually then paste it in /home/deax/.buildozer/android/platform/ it should fix that error

Had the same issue. Turns out it was my proxy setting that caused trouble when downloading files, i.e. I removed http_proxy and https_proxy and then it worked. Hope, that helps.

Looks like the NDK download URL has been a bit of a moving target.

two ways I was able to resolve this:

option 1) to get buildozer to perform the download for you by correcting the download URL: <PYTHON_INSTALL_DIR>/site_packages/buildozer/targets/android.py line 316

If anyone have difficulties to finding this: python -m site --user-site or python3 -m site --user-site