buildozer: IOError: [Errno 2] No such file or directory: "/home/andrew/CODE/Python/kivy-test-android/.buildozer/android/platform/python-for-android/dist/helloworld/bin/HelloWorld-'1.0'-debug.apk"

Traceback (most recent call last):
  File "/usr/local/bin/buildozer", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 987, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 85, in run_commands
    func(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 97, in cmd_debug
    self.buildozer.build()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 198, in build
    self.target.build_package()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 730, in build_package
    copyfile(join(dist_dir, 'bin', apk), join(self.buildozer.bin_dir, apk))
  File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
    with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: "/home/andrew/CODE/Python/kivy-test-android/.buildozer/android/platform/python-for-android/dist/helloworld/bin/HelloWorld-'1.0'-debug.apk"

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 53 (7 by maintainers)

Commits related to this issue

Most upvoted comments

the problem is : in toolchain.py has two build_type ,gradle(build_tools_version>25.0 and exist gradlew) otherwise ant. but in android.py, only jude exist gradlew but the default build_tools_version is 19.1. Fix it: /usr/local/lib/python2.7/dist-packages/buildozer/tagets/android.py,: (1) at file top insert : from distutils.version import LooseVersion (2) line 786 replace with below code:

XXX found how the apk name is really built from the title

__sdk_dir = self.android_sdk_dir build_tools_versions = os.listdir(join(__sdk_dir, ‘build-tools’)) build_tools_versions = sorted(build_tools_versions, key=LooseVersion) build_tools_version = build_tools_versions[-1] gradle_files = [“build.gradle”, “gradle”, “gradlew”] is_gradle_build = any((exists(join(dist_dir, x)) for x in gradle_files)) and build_tools_version >= ‘25.0’ @cdyangbo #312

Can someone just push this fix in? I had to do this hack 4 months ago, and I had to do it again on a new build : (

the problem is : in toolchain.py has two build_type ,gradle(build_tools_version>25.0 and exist gradlew) otherwise ant. but in android.py, only jude exist gradlew but the default build_tools_version is 19.1. Fix it: /usr/local/lib/python2.7/dist-packages/buildozer/tagets/android.py,: (1) at file top insert : from distutils.version import LooseVersion (2) line 786 replace with below code:

XXX found how the apk name is really built from the title

__sdk_dir = self.android_sdk_dir
build_tools_versions = os.listdir(join(__sdk_dir, 'build-tools'))
build_tools_versions = sorted(build_tools_versions, key=LooseVersion)
build_tools_version = build_tools_versions[-1]
gradle_files = ["build.gradle", "gradle", "gradlew"]
is_gradle_build = any((exists(join(dist_dir, x)) for x in gradle_files)) and build_tools_version >= '25.0'

Hi cdyangbo; I think the line should be number: (2) line 789

the problem is : in toolchain.py has two build_type ,gradle(build_tools_version>25.0 and exist gradlew) otherwise ant. but in android.py, only jude exist gradlew but the default build_tools_version is 19.1.
Fix it: /usr/local/lib/python2.7/dist-packages/buildozer/tagets/android.py,:
(1) at file top insert : from distutils.version import LooseVersion
(2) line 786 replace with below code:

    XXX found how the apk name is really built from the title

    __sdk_dir = self.android_sdk_dir
    build_tools_versions = os.listdir(join(__sdk_dir, 'build-tools'))
    build_tools_versions = sorted(build_tools_versions, key=LooseVersion)
    build_tools_version = build_tools_versions[-1]
    gradle_files = ["build.gradle", "gradle", "gradlew"]
    is_gradle_build = any((exists(join(dist_dir, x)) for x in gradle_files)) and build_tools_version >= '25.0'

After taking a closer look, it looks like a slightly different issue. I see: [INFO]: # Found APK file: /path/to/my/appdir/.buildozer/android/platform/build/dists/myapp/bin/myapp-0.1-debug.apk

And the path that is causing the problem is: /path/to/my/appdir/.buildozer/android/platform/build/dists/myapp/build/outputs/apk/myapp-debug.apk

This is because /path/to/my/appdir/.buildozer/android/platform/build/dists/myapp/build does not exist.

Is this the same issue or a new one?

the problem is : in toolchain.py has two build_type ,gradle(build_tools_version>25.0 and exist gradlew) otherwise ant. but in android.py, only jude exist gradlew but the default build_tools_version is 19.1. Fix it: /usr/local/lib/python2.7/dist-packages/buildozer/tagets/android.py,: (1) at file top insert : from distutils.version import LooseVersion (2) line 786 replace with below code:

XXX found how the apk name is really built from the title

__sdk_dir = self.android_sdk_dir
build_tools_versions = os.listdir(join(__sdk_dir, 'build-tools'))
build_tools_versions = sorted(build_tools_versions, key=LooseVersion)
build_tools_version = build_tools_versions[-1]
gradle_files = ["build.gradle", "gradle", "gradlew"]
is_gradle_build = any((exists(join(dist_dir, x)) for x in gradle_files)) and build_tools_version >= '25.0'

works fine! Thanks a lot

Hi @metulburr I found “android.py” in “/home/ratnesh/anaconda3/lib/python3.6/site-packages/buildozer-0.35.dev0-py3.6.egg/buildozer/targets”

Basically it is in lib folder of your default Python where python packages get installed. So manually search “android.py” in this folder.

@cdyangbo solved for me. Thanks.

Thanks for the quick answer! I solved it by replacing my android.py file with this one pushed three days ago: #597

This change fixed it for me

ant_files = ["build.xml", "ant.propeties"]
is_ant_build = any((
   exists(join(dist_dir, x)) for x in ant_files))

if not is_ant_build:
   ....

But this is absolutely a hack, there must be a better way to check what kind of build was run and what kind of APK name was generated. (This is all on python 2.7 btw)

I am getting this error also. The file exists but the wrong name for the file in being given in the copy task.

Traceback (most recent call last):
  File "/usr/local/bin/buildozer", line 9, in <module>
    load_entry_point('buildozer==0.34', 'console_scripts', 'buildozer')()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 1058, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 92, in run_commands
    func(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 104, in cmd_debug
    self.buildozer.build()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 212, in build
    self.target.build_package()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 817, in build_package
    copyfile(join(apk_dir, apk), join(self.buildozer.bin_dir, apk_dest))
  File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
    with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: u'/home/freshollie/Documents/Repos/cashpassport-tracker/.buildozer/android/platform/build/dists/cashpassporttracker/build/outputs/apk/cashpassporttracker-debug.apk'

However the APK is clearly in the directory.

freshollie@freshollie-desktop:~$ ls /home/freshollie/Documents/Repos/cashpassport-tracker/.buildozer/android/platform/build/dists/cashpassporttracker/bin
AndroidManifest.xml    CashPassportTrackerService-0.4.1.ap_        CashPassportTrackerService-0.4.1-debug-unaligned.apk    classes.dex    proguard.txt  rsObj
AndroidManifest.xml.d  CashPassportTrackerService-0.4.1.ap_.d      CashPassportTrackerService-0.4.1-debug-unaligned.apk.d  classes.dex.d  res
build.prop             CashPassportTrackerService-0.4.1-debug.apk  classes                                                 dexedLibs      rsLibs

I have not changed by build script, pretty sure this is due to recent buildozer update.

same issue for me works this edit buildozer.spec [buildozer] build_dir = /build/yourapp