Buildozer: BUILD FAILED: gradlew failed!

Created on 12 Mar 2019  路  9Comments  路  Source: kivy/buildozer

Versions

Python: 3.7
OS: Ubuntu 16.04
Buildozer: 0.40.dev0
Kivy: 1.10.1
Cython: 0.29
Javac: 9-internal
NDK: r17c
SDK: 28

Description
Unable to build apk with gradle after successfully creating the distribution package. I'm getting javac related errors and no python to compile in zip.

Command:
python -m buildozer android debug (python3.7==python)

Spec
[app]

    title = Space Square

    package.name = SpaceFX

    package.domain = Distrosonics.com

    source.dir = .

    source.include_exts = py,png,jpg,kv,atlas,wav

    version = 1.0

    requirements = python3,kivy==1.10.1,pyjnius,numpy,sounddevice,soundfile

    orientation = all

    osx.python_version = 3.7.1

    osx.kivy_version = 1.10.1

    fullscreen = 0

    android.api = 28

    android.arch = arm64-v8a

    [buildozer]

    log_level = 2

    warn_on_root = 1

Log
[INFO]: Selecting java build tool:
[INFO]: Detected highest available build tools version to be 28.0.3
[INFO]: Building with gradle, as gradle executable is present
[DEBUG]: -> running gradlew assembleDebug
[DEBUG]:
[DEBUG]: FAILURE: Build failed with an exception.
[DEBUG]:
[DEBUG]: * What went wrong:
[DEBUG]: Execution failed for task ':compileDebugJavaWithJavac'.
[DEBUG]: > java.lang.reflect.UndeclaredThrowableException
[DEBUG]:
[DEBUG]: * Try:
[DEBUG]: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[DEBUG]:
[DEBUG]: * Get more help at https://help.gradle.org
[DEBUG]:
[DEBUG]: BUILD FAILED in 24s
[DEBUG]: 15 actionable tasks: 15 executed
[DEBUG]:
[DEBUG]:
Exception in thread background thread for pid 15063:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(self._args, *self._kwargs)
File "/home/distorta/.local/lib/python3.7/site-packages/sh.py", line 1540, in wrap
fn(args, *kwargs)
File "/home/distorta/.local/lib/python3.7/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/distorta/.local/lib/python3.7/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/distorta/.local/lib/python3.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

  RAN: /home/distorta/Desktop/Shaped/.buildozer/android/platform/build/dists/SpaceFX/gradlew assembleDebug

  STDOUT:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> java.lang.reflect.UndeclaredThrowableException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 24s
15 actionable tasks: 15 executed




  STDERR:

[INFO]:    STDOUT:

FAILURE: Build failed with an exception.    

* What went wrong:  
Execution failed for task ':compileDebugJavaWithJavac'. 
> java.lang.reflect.UndeclaredThrowableException    

* Try:  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.    

* Get more help at https://help.gradle.org  

BUILD FAILED in 24s 
15 actionable tasks: 15 executed    

[INFO]:    STDERR:

[INFO]:    COMMAND:
cd /home/distorta/Desktop/Shaped/.buildozer/android/platform/build/dists/SpaceFX && /home/distorta/Desktop/Shaped/.buildozer/android/platform/build/dists/SpaceFX/gradlew assembleDebug

[WARNING]: ERROR: /home/distorta/Desktop/Shaped/.buildozer/android/platform/build/dists/SpaceFX/gradlew failed!
WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
No compiled python is present to zip, skipping.
Applying Java source code patches...
Applying patch: src/patches/SDLActivity.java.patch
# Command failed: /usr/bin/python3.7 -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name SpaceFX --name 'Space Square' --version 1.0 --package distrosonics.com.spacefx --android_api 28 --minsdk 21 --ndk-api 21 --private /home/distorta/Desktop/Shaped/.buildozer/android/app --orientation sensor --window --copy-libs --arch arm64-v8a --color=always --storage-dir="/home/distorta/Desktop/Shaped/.buildozer/android/platform/build" --ndk-api=21
# 
# 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

All 9 comments

Nevermind I was able to have a successful build by using Oracles Java 8 not open jdk.

sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer**

Thanks for coming back to that issue with an update.
That's still weird however since we're using openjdk-8-jdk on both buildozer and p4a Docker containers and it works fine

Command:
python -m buildozer android debug deploy run logcat

So apparently the build was "successful" but the apk itself is unable to run. There is a no compiled python is present to zip and the java patch failed (exit code 1). Any ideas?

LOG:
[DEBUG]: -> running gradlew assembleDebug
[DEBUG]:
[DEBUG]: BUILD SUCCESSFUL in 14s
[DEBUG]: 27 actionable tasks: 4 executed, 23 up-to-date

[INFO]:    <- directory context /home/distorta/Desktop/Shaped/.buildozer/android/platform/python-for-android
[INFO]:    # Copying APK to current directory
[INFO]:    # APK filename not found in build output. Guessing...
[INFO]:    # Found APK file: /home/distorta/Desktop/Shaped/.buildozer/android/platform/build/dists/SpaceFX/build/outputs/apk/debug/SpaceFX-debug.apk
[INFO]:    # Add version number to APK
[INFO]:    # APK renamed to SpaceFX-1.0-debug.apk
[DEBUG]:   -> running cp /home/distorta/Desktop/Shaped/.buildozer/android/platform/build/dists/SpaceFX/build/outputs/apk/debug/SpaceFX-debug.apk SpaceFX-1.0-debug.apk
WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
No compiled python is present to zip, skipping.
Applying Java source code patches...
Applying patch: src/patches/SDLActivity.java.patch
Warning: failed to apply patch (exit code 1), assuming it is already applied: src/patches/SDLActivity.java.patch
# Android packaging done!
# APK SpaceFX-1.0-debug.apk available in the bin directory
# Run '/home/distorta/.buildozer/android/platform/android-sdk/platform-tools/adb devices'
# Cwd None
List of devices attached

# Application pushed.
# Application started.
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.18.4 (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 /usr/local/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-9-openjdk-amd64/bin/keytool

OK can you try building it from Docker?

docker run \
  --volume "$HOME/.buildozer":/home/user/.buildozer \
  --volume "$PWD":/home/user/hostcwd \
  kivy/buildozer android debug

Deployment is not yet working from Docker, but you can deploy the APK directly with adb install outside Docker.
Also you may need to clean your ~/.buildozer and .buildozer directories as they could clash with Docker. So before running the build from Docker you can go to your project dir and:

rm -rf ~/.buildozer .buildozer && mkdir ~/.buildozer`

I could use Docker, but I am not really familiar with it yet and I'll need to set some time aside to figure that out. As for using just Buildozer I was able to use android studios debugger after the buildozer apk was compiled and I got this error: No module named '_cffi_backend'. I installed cffi build-essential libssl-dev libffi-dev python-dev with pip and still getting the module error.

Here is a stack that helped me out:
https://stackoverflow.com/questions/34370962/no-module-named-cffi-backend

I had to force reinstall cffi and upgrade pip -vvv install --upgrade --force-reinstall cffi to make sure FFI() could be instantiated in python. Then I included cffi in the specs under requirements to get past the error. I was using sounddevice so I had included that in the requirements but left out cffi because it was a requirement by sounddevice.

However:
sounddevice requires pyaudio that is built on portaudios c/c++ bindings and 3.7 is not compatible with pyaudio. So I have to use python 3.6. At this point because of how finicky the recipes are I am going to have to just use kivy's native sound player that is more limited. Unless, anyone knows of a good standing recipe of versions to use in this build, especially with cython, that works with python 3.7

`[INFO]: Selecting java build tool:
Exception in thread background thread for pid 16125:
Traceback (most recent call last):
File "/home/joshua/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/home/joshua/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(self._args, *self._kwargs)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 1540, in wrap
fn(args, *kwargs)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build/dists/myapp/gradlew assembleDebug

STDOUT:
Unzipping /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5/gradle-4.4-all.zip to /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:157)
at org.gradle.wrapper.Install.access$400(Install.java:26)
at org.gradle.wrapper.Install$1.call(Install.java:67)
at org.gradle.wrapper.Install$1.call(Install.java:44)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)

STDERR:

Unzipping /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5/gradle-4.4-all.zip to /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5

Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:157)
at org.gradle.wrapper.Install.access$400(Install.java:26)
at org.gradle.wrapper.Install$1.call(Install.java:67)
at org.gradle.wrapper.Install$1.call(Install.java:44)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
cd /home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build/dists/myapp && /home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build/dists/myapp/gradlew assembleDebug

WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
No compiled python is present to zip, skipping.
No setup.py/pyproject.toml used, copying full private data into .apk.
Applying Java source code patches...
Applying patch: src/patches/SDLActivity.java.patch
Warning: failed to apply patch (exit code 1), assuming it is already applied: src/patches/SDLActivity.java.patch

Command failed: /home/joshua/anaconda3/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --android_api 27 --minsdk 21 --ndk-api 21 --private /home/joshua/Documents/myProjects/firstapp/.buildozer/android/app --orientation portrait --window --copy-libs --arch armeabi-v7a --color=always --storage-dir="/home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build" --ndk-api=21

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

somebody to help me, still the error exists a almost five months now I can't move on with my project

`INFO: Selecting java build tool:
INFO: Detected highest available build tools version to be 29.0.0-rc3
INFO: Building with gradle, as gradle executable is present
[DEBUG]: -> running gradlew assembleDebug
[DEBUG]: Unzipping /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5/gradle-4.4-all.zip to /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5
[DEBUG]: Exception in thread "main" java.util.zip.ZipException: error in opening zip file
[DEBUG]: at java.util.zip.ZipFile.open(Native Method)
[DEBUG]: at java.util.zip.ZipFile.(ZipFile.java:225)
[DEBUG]: at java.util.zip.ZipFile.(ZipFile.java:155)
[DEBUG]: at java.util.zip.ZipFile.(ZipFile.java:169)
[DEBUG]: at org.gradle.wrapper.Install.unzip(Install.java:157)
[DEBUG]: at org.gradle.wrapper.Install.access$400(Install.java:26)
[DEBUG]: at org.gradle.wrapper.Install$1.call(Install.java:67)
[DEBUG]: at org.gradle.wrapper.Install$1.call(Install.java:44)
[DEBUG]: at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
[DEBUG]: at org.gradle.wrapper.Install.createDist(Install.java:44)
[DEBUG]: at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
[DEBUG]: at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
Exception in thread background thread for pid 16125:
Traceback (most recent call last):
File "/home/joshua/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/home/joshua/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(self._args, *self._kwargs)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 1540, in wrap
fn(args, *kwargs)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/joshua/anaconda3/lib/python3.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build/dists/myapp/gradlew assembleDebug

STDOUT:
Unzipping /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5/gradle-4.4-all.zip to /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:157)
at org.gradle.wrapper.Install.access$400(Install.java:26)
at org.gradle.wrapper.Install$1.call(Install.java:67)
at org.gradle.wrapper.Install$1.call(Install.java:44)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)

STDERR:

Unzipping /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5/gradle-4.4-all.zip to /home/joshua/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:157)
at org.gradle.wrapper.Install.access$400(Install.java:26)
at org.gradle.wrapper.Install$1.call(Install.java:67)
at org.gradle.wrapper.Install$1.call(Install.java:44)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
INFO: STDERR:

cd /home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build/dists/myapp && /home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build/dists/myapp/gradlew assembleDebug

[WARNING]: ERROR: /home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build/dists/myapp/gradlew failed!
WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
No compiled python is present to zip, skipping.
No setup.py/pyproject.toml used, copying full private data into .apk.
Applying Java source code patches...
Applying patch: src/patches/SDLActivity.java.patch
Warning: failed to apply patch (exit code 1), assuming it is already applied: src/patches/SDLActivity.java.patch

Command failed: /home/joshua/anaconda3/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --android_api 27 --minsdk 21 --ndk-api 21 --private /home/joshua/Documents/myProjects/firstapp/.buildozer/android/app --orientation portrait --window --copy-libs --arch armeabi-v7a --color=always --storage-dir="/home/joshua/Documents/myProjects/firstapp/.buildozer/android/platform/build" --ndk-api=21

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

somebody to help me, still the error exists a almost five months now I can't move on with my project

Delete your .gradle folder in your home directory. It is probably corrupted. Run the command again. Worked for me.

Delete the .gradle folder in your home directory. Once u do this run the command again, then the buildozer will download the Gradle once again and the app will be built without any problems.

Try to run this command: sudo rm -rf ~/.gradle

Was this page helpful?
0 / 5 - 0 ratings