Hello world with kivy + python-for-android + buildozer on ubuntu 16.04 with pyhton 2.7

82 views
Skip to first unread message

Stefan Pappalardo

unread,
Apr 15, 2018, 9:31:13 AM4/15/18
to Kivy users support
I've tried to use kivy (with python-for-android + buildozer) on ubuntu 16.04. with python 2.7 in virtualenv. I've tried it with python-for-android only and with buildozer. Both ways are producing errors. I followed exactly the getting started guide from kivy.org. I don't know what is wrong.  I did not expect the process of getting an hello world app on my android phone to be so difficult. Is there any one who can share the complete way (with installed versions by "pip freeze" for example)?

Sanjoy Ghosh

unread,
Apr 15, 2018, 10:20:26 AM4/15/18
to kivy-...@googlegroups.com
Use kivy VMbox....read below link post

On Sun 15 Apr, 2018, 7:01 PM Stefan Pappalardo, <stefan.p...@gmail.com> wrote:
I've tried to use kivy (with python-for-android + buildozer) on ubuntu 16.04. with python 2.7 in virtualenv. I've tried it with python-for-android only and with buildozer. Both ways are producing errors. I followed exactly the getting started guide from kivy.org. I don't know what is wrong.  I did not expect the process of getting an hello world app on my android phone to be so difficult. Is there any one who can share the complete way (with installed versions by "pip freeze" for example)?

--
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.
For more options, visit https://groups.google.com/d/optout.

Stefan Pappalardo

unread,
Apr 15, 2018, 2:06:41 PM4/15/18
to Kivy users support
OK. I've tried and got the following error.

# Android packages installation done.
# Check application requirements
# Check garden requirements
# Compile platform
# Build the application #1
# Package the application
# Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/home/kivy/Desktop/hello/.buildozer/android/platform/build apk --bootstrap=sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --android_api 19 --minsdk 9 --private /home/kivy/Desktop/hello/.buildozer/android/app --orientation landscape --copy-libs
#
# Buildozer failed to execute the last command
# If the error is not obvious, please raise the log_level to 2
# and retry the latest command.
# In case of a bug report, please add a full log with log_level = 2

Stefan Pappalardo

unread,
Apr 15, 2018, 2:10:00 PM4/15/18
to Kivy users support
And some mor information with log level switched to debug...
BUILD FAILED
/home/kivy/.buildozer/android/platform/android-sdk-20/tools/ant/build.xml:720: The following error occurred while executing this line:
/home/kivy/.buildozer/android/platform/android-sdk-20/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Total time: 3 seconds


  STDERR:


[INFO]:    STDOUT (last 20 lines of 75):
       
-pre-compile:   
   
-compile:   
    [javac] Compiling 26 source files to /home/kivy/Desktop/hello/.buildozer/android/platform/build/dists/myapp/bin/classes   
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release   
    [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release   
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.   
    [javac] /home/kivy/Desktop/hello/.buildozer/android/platform/build/dists/myapp/tmp-src/org/kivy/android/PythonService.java:108: error: multi-catch statement is not supported in -source 1.5   
    [javac]             } catch (NoSuchMethodException | IllegalAccessException |   
    [javac]                                            ^   
    [javac]   (use -source 7 or higher to enable multi-catch statement)   
    [javac] 1 error   
    [javac] 3 warnings   
   
BUILD FAILED   
/home/kivy/.buildozer/android/platform/android-sdk-20/tools/ant/build.xml:720: The following error occurred while executing this line:   
/home/kivy/.buildozer/android/platform/android-sdk-20/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.   
   
Total time: 3 seconds
[INFO]:    STDERR:
   
[INFO]:    COMMAND:
cd /home/kivy/Desktop/hello/.buildozer/android/platform/build/dists/myapp && /home/kivy/.buildozer/android/platform/apache-ant-1.9.4/bin/ant debug

[WARNING]: ERROR: /home/kivy/.buildozer/android/platform/apache-ant-1.9.4/bin/ant failed!

# Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/home/kivy/Desktop/hello/.buildozer/android/platform/build apk --bootstrap=sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --android_api 19 --minsdk 9 --private /home/kivy/Desktop/hello/.buildozer/android/app --orientation landscape --copy-libs
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.

# In case of a bug report, please add a full log with log_level = 2


Sanjoy Ghosh

unread,
Apr 15, 2018, 2:13:08 PM4/15/18
to kivy-...@googlegroups.com
In buildozer.spec file 
Make log level 2,
And
Search "buidozer issue 521" 

Sanjoy Ghosh

unread,
Apr 15, 2018, 2:14:43 PM4/15/18
to kivy-...@googlegroups.com
Pls don't change any path ....in kivy machine

Stefan Pappalardo

unread,
Apr 15, 2018, 4:44:28 PM4/15/18
to Kivy users support
I already set log level to debug (2) in buildozer.spec.
And how should buildozer issue 521 (https://github.com/kivy/buildozer/issues/521) help in any way with my current issue?

Stefan Pappalardo

unread,
Apr 15, 2018, 4:45:53 PM4/15/18
to Kivy users support
I did not change any path in kivy machine.

Sanjoy Ghosh

unread,
Apr 16, 2018, 12:39:43 AM4/16/18
to kivy-...@googlegroups.com
chk this and install  packages

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.

Stefan Pappalardo

unread,
Apr 16, 2018, 5:42:08 PM4/16/18
to Kivy users support
OK. That really helped.

# Android packaging done!
# APK MyApplication-0.1-debug.apk available in the bin directory

This should be added to Hints and Tips on https://kivy.org/docs/guide/packaging-android-vm.html?highlight=buildozer

Sanjoy Ghosh

unread,
Apr 19, 2018, 9:10:01 AM4/19/18
to kivy-...@googlegroups.com
Any other problems?

Stefan Pappalardo

unread,
Apr 19, 2018, 2:22:56 PM4/19/18
to Kivy users support
When trying with virtualenv the following error occurs. Do you also have a solution for that error?

[INFO]:    Selecting java build tool:
[INFO]:    Detected highest available build tools version to be 19.1.0
[INFO]:        Building with ant, as the highest build-tools-version is only 19.1.0
[DEBUG]:   -> running ant debug
[DEBUG]:       Buildfile: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/build.xml
[DEBUG]:      
[DEBUG]:       -set-mode-check:
[DEBUG]:      
[DEBUG]:       -set-debug-files:
[DEBUG]:      
[DEBUG]:       -check-env:
[DEBUG]:        [checkenv] Android SDK Tools Revision 22.6.2
[DEBUG]:        [checkenv] Installed at /home/sjuk/.buildozer/android/platform/android-sdk-20
[DEBUG]:      
[DEBUG]:       -setup:
[DEBUG]:            [echo] Project Name: MyApplication-0.1
[DEBUG]:         [gettype] Project Type: Application
[DEBUG]:      
[DEBUG]:       -set-debug-mode:
[DEBUG]:      
[DEBUG]:       -debug-obfuscation-check:
[DEBUG]:      
[DEBUG]:       -pre-build:
[DEBUG]:            [copy] Copying 25 files to /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/tmp-src
[DEBUG]:      
[DEBUG]:       -build-setup:
[DEBUG]:       [getbuildtools] Using latest Build Tools: 19.1.0
[DEBUG]:            [echo] Resolving Build Target for MyApplication-0.1...
[DEBUG]:       [gettarget] Project Target:   Android 4.4.2
[DEBUG]:       [gettarget] API level:        19
[DEBUG]:            [echo] ----------
[DEBUG]:            [echo] Creating output directories if needed...
[DEBUG]:           [mkdir] Created dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin
[DEBUG]:           [mkdir] Created dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res
[DEBUG]:           [mkdir] Created dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/rsObj
[DEBUG]:           [mkdir] Created dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/rsLibs
[DEBUG]:           [mkdir] Created dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/gen
[DEBUG]:           [mkdir] Created dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/classes
[DEBUG]:           [mkdir] Created dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/dexedLibs
[DEBUG]:            [echo] ----------
[DEBUG]:            [echo] Resolving Dependencies for MyApplication-0.1...
[DEBUG]:       [dependency] Library dependencies:
[DEBUG]:       [dependency] No Libraries
[DEBUG]:       [dependency]
[DEBUG]:       [dependency] ------------------
[DEBUG]:            [echo] ----------
[DEBUG]:            [echo] Building Libraries with 'debug'...
[DEBUG]:          [subant] No sub-builds to iterate on
[DEBUG]:      
[DEBUG]:       -code-gen:
[DEBUG]:       [mergemanifest] Merging AndroidManifest files into one.
[DEBUG]:       [mergemanifest] Manifest merger disabled. Using project manifest only.
[DEBUG]:            [echo] Handling aidl files...
[DEBUG]:            [aidl] No AIDL files to compile.
[DEBUG]:            [echo] ----------
[DEBUG]:            [echo] Handling RenderScript files...
[DEBUG]:            [echo] ----------
[DEBUG]:            [echo] Handling Resources...
[DEBUG]:            [aapt] Generating resource IDs...
[DEBUG]:            [aapt]     (skipping file '.gitkeep' due to ANDROID_AAPT_IGNORE pattern '.*')
[DEBUG]:            [echo] ----------
[DEBUG]:            [echo] Handling BuildConfig class...
[DEBUG]:       [buildconfig] Generating BuildConfig class.
[DEBUG]:      
[DEBUG]:       -pre-compile:
[DEBUG]:      
[DEBUG]:       -compile:
[DEBUG]:           [javac] Compiling 26 source files to /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/classes
[DEBUG]:           [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
[DEBUG]:           [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
[DEBUG]:           [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
[DEBUG]:           [javac] Note: Some input files use or override a deprecated API.
[DEBUG]:           [javac] Note: Recompile with -Xlint:deprecation for details.
[DEBUG]:           [javac] 3 warnings
[DEBUG]:      
[DEBUG]:       -post-compile:
[DEBUG]:      
[DEBUG]:       -obfuscate:
[DEBUG]:      
[DEBUG]:       -dex:
[DEBUG]:             [dex] input: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/classes
[DEBUG]:             [dex] Converting compiled files and external libraries into /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/classes.dex...
[DEBUG]:      
[DEBUG]:       -crunch:
[DEBUG]:          [crunch] Crunching PNG Files in source dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/src/main/res
[DEBUG]:          [crunch] To destination dir: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res
[DEBUG]:          [crunch] Processing image to cache: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/src/main/res/drawable-hdpi/ic_launcher.png => /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-hdpi/ic_launcher.png
[DEBUG]:          [crunch]   (processed image to cache entry /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-hdpi/ic_launcher.png: 0% size of source)
[DEBUG]:          [crunch] Processing image to cache: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/src/main/res/drawable-mdpi/ic_launcher.png => /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-mdpi/ic_launcher.png
[DEBUG]:          [crunch]   (processed image to cache entry /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-mdpi/ic_launcher.png: 0% size of source)
[DEBUG]:          [crunch] Processing image to cache: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/src/main/res/drawable-xhdpi/ic_launcher.png => /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-xhdpi/ic_launcher.png
[DEBUG]:          [crunch]   (processed image to cache entry /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-xhdpi/ic_launcher.png: 105% size of source)
[DEBUG]:          [crunch] Processing image to cache: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/src/main/res/drawable-xxhdpi/ic_launcher.png => /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-xxhdpi/ic_launcher.png
[DEBUG]:          [crunch]   (processed image to cache entry /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable-xxhdpi/ic_launcher.png: 59% size of source)
[DEBUG]:          [crunch] Processing image to cache: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/src/main/res/drawable/icon.png => /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable/icon.png
[DEBUG]:          [crunch]   (processed image to cache entry /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/res/drawable/icon.png: 126% size of source)
[DEBUG]:          [crunch] Crunched 5 PNG files to update cache
[DEBUG]:      
[DEBUG]:       -package-resources:
[DEBUG]:            [aapt] Creating full resource package...
[DEBUG]:            [aapt]     (skipping file '.gitkeep' due to ANDROID_AAPT_IGNORE pattern '.*')
[DEBUG]:            [aapt]     (skipping file '.gitkeep' due to ANDROID_AAPT_IGNORE pattern '.*')
[DEBUG]:      
[DEBUG]:       -package:
[DEBUG]:       [apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[DEBUG]:       [apkbuilder] Creating MyApplication-0.1-debug-unaligned.apk and signing it with a debug key...
[DEBUG]:      
[DEBUG]:       -post-package:
[DEBUG]:      
[DEBUG]:       -do-debug:
[DEBUG]:        [zipalign] Running zip align on final apk...
[DEBUG]:            [echo] Debug Package: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/MyApplication-0.1-debug.apk
[DEBUG]:       [propertyfile] Creating new property file: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/build.prop
[DEBUG]:       [propertyfile] Updating property file: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/build.prop
[DEBUG]:       [propertyfile] Updating property file: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/build.prop
[DEBUG]:       [propertyfile] Updating property file: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/build.prop
[DEBUG]:      
[DEBUG]:       -post-build:
[DEBUG]:          [delete] Deleting directory /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/tmp-src
[DEBUG]:      
[DEBUG]:       debug:
[DEBUG]:      
[DEBUG]:       BUILD SUCCESSFUL
[DEBUG]:       Total time: 4 seconds
[INFO]:    <- directory context /home/sjuk/src/myapp/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    # Copying APK to current directory
[INFO]:    # Found APK file: /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/MyApplication-0.1-debug.apk
[DEBUG]:   -> running cp /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/bin/MyApplication-0.1-debug.apk ./
Traceback (most recent call last):
  File "/home/sjuk/env/buildozer/bin/buildozer", line 11, in <module>
    sys.exit(main())
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/__init__.py", line 1058, in run_command
    self.target.run_commands(args)
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/target.py", line 92, in run_commands
    func(args)
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/target.py", line 104, in cmd_debug
    self.buildozer.build()
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/__init__.py", line 212, in build
    self.target.build_package()
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-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/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/build/outputs/apk/myapp-debug.apk'

Am Donnerstag, 19. April 2018 15:10:01 UTC+2 schrieb Sanjoy Ghosh:
Any other problems?

Sanjoy Ghosh

unread,
Apr 20, 2018, 1:02:54 AM4/20/18
to kivy-...@googlegroups.com

--
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+unsubscribe@googlegroups.com.

Stefan Pappalardo

unread,
Apr 28, 2018, 11:45:30 AM4/28/18
to Kivy users support
OK, there are some hacks for that and the apk-file was successfully build lying in the following path:
<path to myapp>/build/android/platform/build/dists/myapp/bin/

Conclusion:
The virtualbox-image is not needed to build
Building with virtualenv on ubuntu 16.04 works
Finding the resulting apk-file is left to the end user

Question:
Do you know if there are any plans to solve the issue with the copying of the apk-file?

By the way:
When leaving the buildozer.spec file with it's defaults (log_level = 1 for info) I would expect that the path to the built apk-file would be written to console.
But it does not. See the complete output below. I had to set log_level = 2 for debug to see the info-message about the build apk-file.
I would recommend to fix this issue at first. When setting log_level to 1 (info), then all info-messages should be shown to the console.
This would make the use of buildozer much more easy and can help by finding the origin or cause of unexpected behaviours.


Thank you in advance

~/src/myapp$ buildozer android debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Install platform
# Apache ANT found at /home/sjuk/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/sjuk/.buildozer/android/platform/android-sdk-20
# Android NDK found at /home/sjuk/.buildozer/android/platform/android-ndk-r9c

# Check application requirements
# Check garden requirements
# Compile platform
# Build the application #2
# Package the application
# Gradle project detected, copy files /home/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/src/main/java

Traceback (most recent call last):
  File "/home/sjuk/env/buildozer/bin/buildozer", line 11, in <module>
    sys.exit(main())
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/__init__.py", line 1058, in run_command
    self.target.run_commands(args)
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/target.py", line 92, in run_commands
    func(args)
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/target.py", line 104, in cmd_debug
    self.buildozer.build()
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-packages/buildozer/__init__.py", line 212, in build
    self.target.build_package()
  File "/home/sjuk/env/buildozer/local/lib/python2.7/site-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/sjuk/src/myapp/.buildozer/android/platform/build/dists/myapp/build/outputs/apk/myapp-debug.apk'


To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

Глеб Самойлов

unread,
Apr 28, 2018, 12:13:25 PM4/28/18
to kivy-...@googlegroups.com
Your apk file in /home/sjuk/src/myapp/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/myapp-debug.apk folder.
This error now occurs in everyone!

воскресенье, 15 апреля 2018 г., 16:31:13 UTC+3 пользователь Stefan Pappalardo написал:

Stefan Pappalardo

unread,
Apr 28, 2018, 12:26:30 PM4/28/18
to Kivy users support
???
Reply all
Reply to author
Forward
0 new messages