Creating an Android app in KivyMD with buildozer OS: Ubuntu 22.04.3 LTS (In Windows 10 over WSL) The problem: Running into an error with Gradle called (gradle failed)
I've been trying to create an Android app with KivyMD an buildozer via running the command: buildozer android debug.
The Python code:
from kivymd.app import MDApp
from kivy.lang import Builder
from kivymd.uix.screen import MDScreen
def one_and_zero(string: str):
for i in string:
if i == '1' or i == '0':
pass
else:
return False
return True
class Home(MDScreen):
def get_data(self):
x = str(self.ids.input.text)
try:
if x[2:].isnumeric() and x[:2] == "0b":
self.ids.ans.text = str(eval(x))
else:
self.ids.ans.text = str(bin(int(x)))[2:]
except:
self.ids.ans.text = "Invaled value"
class Asciilator(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Indigo"
return Builder.load_file('design.kv')
if __name__ == "__main__":
Asciilator().run()
The "design.kv" file:
MDScreenManager:
Home:
<Home>:
name: "Home"
MDLabel:
text: ""
id: ans
pos_hint: {"center_x": 1,"center_y": .9}
MDCard:
pos_hint: {"center_x": .5, "center_y": .5}
size_hint: .95, .5
FloatLayout:
MDRoundFlatButton:
text: "Calc"
pos_hint: {"x": .8, "y": .45}
on_release: root.get_data()
MDTextField:
id: input
hint_text: "Insert the code"
size_hint: None,None
width: '200dp'
pos_hint: {"x": .1, "y": .4}
on_text_validate: root.get_data()
And here is the buildozer's log:
[INFO]: COMMAND:
cd /home/hashem207/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/asciilator && /home/hashem207/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/asciilator/gradlew clean assembleDebug
[WARNING]: ERROR: /home/hashem207/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/asciilator/gradlew failed!
No setup.py/pyproject.toml used, copying full private data into .apk.
Applying Java source code patches...
Applying patch: src/patches/SDLActivity.java.patch
And finaly, The "buildozer.spec" file:
[app]
# (str) Title of your application
title = Asciilator
# (str) Package name
package.name = asciilator
# (str) Package domain (needed for android/ios packaging)
package.domain = everysolver.org
# (str) Soucre code where the main.py live
source.dir = ./Project/
# (list) Source files to include (let empty to include all the files)
source.include_exts = py, png, kv, json
# (list) List of inclusions using pattern matching
#source.include_patterns = assets/*,images/*.png
# (list) Source files to exclude (let empty to not exclude anything)
source.exclude_exts = spec
# (list) List of directory to exclude (let empty to not exclude anything)
source.exclude_dirs = tests, bin, android_venv, .buildozer
# (list) List of exclusions using pattern matching
# Do not prefix with './'
#source.exclude_patterns = license,images/*/*.jpg
# (str) Application versioning (method 1)
version = 1.0.1
# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = kivy==2.3.0,kivymd==1.1.1,pillow==10.2.0
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy
# (str) Presplash of the application
#presplash.filename = ./Project/icon.png
# (str) Icon of the application
icon.filename = ./Project/icon.png
# (list) Supported orientations
# Valid options are: landscape, portrait, portrait-reverse or landscape-reverse
orientation = portrait
# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
#
# OSX Specific
#
#
# author = © Copyright Info
# change the major version of python used by the app
osx.python_version = 3.10.12
# Kivy version to use
osx.kivy_version = 2.3.0
#
# Android specific
#
# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0
# (string) Presplash background color (for android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
# olive, purple, silver, teal.
#android.presplash_color = #FFFFFF
# (string) Presplash animation using Lottie format.
# see https://lottiefiles.com/ for examples and https://airbnb.design/lottie/
# for general documentation.
# Lottie files can be created using various tools, like Adobe After Effect or Synfig.
android.presplash_lottie = ./Project/start.json
# (str) Adaptive icon of the application (used if Android API level is 26+ at runtime)
#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png
#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png
# (list) Permissions
# (See https://python-for-android.readthedocs.io/en/latest/buildoptions/#build-options-1 for all the supported syntaxes and properties)
#android.permissions = android.permission.INTERNET, (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18)
# (list) features (adds uses-feature -tags to manifest)
#android.features = android.hardware.usb.host
# (int) Target Android API, should be as high as possible.
#android.api = 34
# (int) Minimum API your APK / AAB will support.
#android.minapi = 21
# (int) Android SDK version to use
#android.sdk = 20
# (str) Android NDK version to use
#android.ndk = 26b
# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
#android.ndk_api = 21