4

So I have spent some time developing a recipe app: Github I can use with my Raspberry Pi, which works great and I don't mind using a launcher for the raw code there. However I wanted to be able to package the Kivy application as an apk using the buildozer method:

buildozer android debug deploy run

Which compiles successfully and the apk installs fine, however the application crashes after a second, after that I tried using the Kivy Launcher which never seems to recognise my program, so i moved on to trying to run the raw code through Pydroid 3, which has worked in the past for both Kivy and KivyMD however it crashes trying this import which isnt a part of my code:

from android.config import JAVA_NAMESPACE, JNI_NAMESPACE

my buildozer.spec file is:

https://github.com/treencd/RecipeBook/blob/master/buildozer.spec

I eventually tried using:

adb logcat

However the output doesn't seem that helpful or I dont know what i'm looking for.

I could really use some direction on how to go about debugging an application like this.

Craig
  • 41
  • 1
  • 2
  • Ok so I followed @inclement 's suggestion and deleted the .buildozer directory, used the Buildozer requirements: `requirements = python3,Pillow,kivy,kivymd,android` full .buildozer.spec file: buildozer.spec Then ran: `buildozer android debug deploy run` This succeeded this time without error, so I tried running the apk on android and I got this error from the `logcat`: logcat – Craig Dec 18 '19 at 14:38
  • sorry, spec file: https://drive.google.com/file/d/1E4m6sNkSsy33km2NXeEz-ayDFYBq8x1x/view?usp=sharing logcat: https://drive.google.com/file/d/1VcMrU6VWfqPIhvga5sVeMsY6kca8hfVT/view?usp=sharing The error is essentially: `ValueError: KivyMD: App object should be inherited from 'kivymd.app.MDApp'` but KivyMD has no attribute called 'app' – Craig Dec 18 '19 at 14:49

2 Answers2

4

You need 3 steps (omitted enabling debug mode on cellphone). You can save each step as bash files then run the scripts easily. Assuming the folder structure below

project/
    1.bash
    2.bash
    3.bash
    bin/
        random_name.apk
    main.py
    main.kv

1) Build apk (1.bash)

#!/bin/sh
buildozer -v android debug

2) Install on cellphone from terminal (2.bash)

#!/bin/sh
adb install -r bin/*.apk

3) Running the apk and see what's happening (3.bash)

#!/bin/sh
echo 'Please connect on transfer files mode the cellphone'
adb logcat -s "python"

Then when all is working just create a new file (0.bash)

#!/bin/sh

bash 1.bash
bash 2.bash
bash 3.bash
Pablo Díaz
  • 330
  • 4
  • 14
1

Using adb logcat is the way to go. Amongst (many) other things, this includes all the normal logging output of your application, just as you would see on the desktop. You can also do more advanced debugging, but this is usually sufficient for debugging basic issues (just as on the desktop, seeing the traceback is most of the information you often need).

The python-related lines in the output all have the tag "python". There's an adb syntax for showing only output matching a specific tag, but I can never remember it and just use grep - adb logcat | grep python is fine.

If this doesn't return anything runtime python output, it means that the application is crashing before getting to that point, and you'll have to more carefully inspect the logcat. If this is the case, post the logcat here.

inclement
  • 29,124
  • 4
  • 48
  • 60
  • The command `adb logcat | grep python` cleaned up the output tremendously, after this I found this error message: `12-17 20:01:56.791 25447 25481 I python : ModuleNotFoundError: No module named 'PIL'` do I need to include the python `pillow` package in the build requirements then? – Craig Dec 18 '19 at 01:06
  • If you want to import PIL then yes. If you aren't trying to do that then this message is likely to be a red herring from within Kivy. – inclement Dec 18 '19 at 01:18
  • I do need PIL for an image cropper in the app, so I tried building with `pillow`, `PIL`, and `Pillow`, just to be sure but the buildozer command failed every time on the requirements line, maybe I should include the pillow source code in my directory? – Craig Dec 18 '19 at 01:40
  • It looks like `Pillow` is the correct recipe name to use. I thought this build was currently working, could you post the error you get (and start the build from scratch by deleting the .buildozer directory in your build dir first)? – inclement Dec 18 '19 at 12:08