Buildozer error while compiling for Android

2,787 views
Skip to first unread message

Shoumik Das

unread,
Nov 16, 2020, 5:51:41 AM11/16/20
to Kivy users support
Hi, I am trying to compile a Kivy app to an Android apk. I get the following error at the very end of the process. Can someone please advise? The buildozer on-screen debug log and buildozer spec files are attached for reference.

Please advise.
buildozer.log
buildozer.spec

planckp...@gmail.com

unread,
Nov 16, 2020, 12:13:32 PM11/16/20
to Kivy users support
Probably:
All characters must be alphanumeric or an underscore [a-zA-Z0-9_].

Shoumik Das

unread,
Nov 16, 2020, 1:38:23 PM11/16/20
to Kivy users support
Hi there, I am sorry I did not understand what you suggested. Can you please help me understand? I searched the buildozer.spec file but I could not find any parameter called application id.

Can you kindly help me out here? I am unable to fix this issue. Is there any mismatch between the android sdk version and build tools version?

Message has been deleted

planckp...@gmail.com

unread,
Nov 16, 2020, 2:19:17 PM11/16/20
to Kivy users support

Shoumik Das

unread,
Nov 16, 2020, 11:52:09 PM11/16/20
to Kivy users support
That fixed the compile issue. Thank you. The android apk is now getting compiled and installed on my android phone but when I launch it, it simply crashes without any error message. When I click on the app icon on my phone, the Kivy splash screen comes up with a "Loading..." message and then it shuts down. What could be going wrong here?

Are the android api selections okay in the spec file?

requirements = python3,kivy,android,kivmob,jnius,mysql_connector
android.permissions = INTERNET, ACCESS_NETWORK_STATE
# (int) Target Android API, should be as high as possible.
android.api = 27
# (int) Minimum API your APK will support.
android.minapi = 21
# (int) Android SDK version to use
#android.sdk = 24
# (str) Android NDK version to use
android.ndk = 19c
android.gradle_dependencies ='com.google.firebase:firebase-ads:10.2.0'

Can you please advise?

Thanks in advance.

planckp...@gmail.com

unread,
Nov 17, 2020, 12:44:20 AM11/17/20
to Kivy users support
Can you please advise?
Read around the subject, the answers to these questions are easy to find. You are smart enough to find them, that process is how we learn to address issues.

The app crashed, due to a fatal error. Run the debugger.

The error will be in the logcat output. Usually the issue is found following the word "Traceback" where you will see the Python stack dump, the last line of which is the most important. Depending on the error, the issue may be elsewhere in the logcat.

Android debugging requires a USB connection and the Android device with both 'developer mode' (google this) with 'USB debugging' enabled on the phone. This is not Kivy specific.

Shoumik Das

unread,
Nov 17, 2020, 3:58:48 AM11/17/20
to Kivy users support
Hi there. Thanks for the information. I am new to Kivy and compiling apps for Android and I was not aware of the logcat feature. I will try your suggestions. In the meantime, I did some search on Google and changed the requirements section for my app. Now, my app is not compiling into an apk. So, I can't deploy into a phone.

requirements = python3==3.6.9,kivy,android,kivmob,jnius,mysql_connector,pysftp,tweepy,openssl

I specified the exact version of Python that the Kivy app runs on in my desktop (3.6.9). I had recently tested with 3.8.x and the desktop app had crashed. So I was wondering that it might have something to do with the Python version. I also inlcuded pysftp, tweepy and openssl. When I compiled, I got a linker error. As per an earlier warning message, lld was not installed. So. I installed lld on my system (Ubuntu 18.0.4) with sudo apt install lld and recompiled again.

Now, the compilation failed with the following error. Maybe, if I can get this code to compile, I will try your suggestion of using logcat. I looked around the Traceback word. This is what I get:

Fatal: You must get working getaddrinfo() function.
       or you can specify "--disable-ipv6".

  STDERR:

# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=SIVA --bootstrap=sdl2 --requirements=python3==3.6.9,kivy,android,kivmob,jnius,mysql_connector,pysftp,tweepy,openssl --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/neo/code/siva-android/v1.1/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21 --ignore-setup-py


  STDERR:

                                                                                                                                             
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1260, in <module>
    main()
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
    ToolchainCL()
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 709, in __init__
    getattr(self, command)(args)
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 216, in build_dist_from_args
    args, "ignore_setup_py", False
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 577, in build_recipes
    recipe.build_arch(arch)
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/recipes/python3/__init__.py", line 310, in build_arch
    _env=env)
  File "/home/neo/code/siva-android/v1.1/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
    for line in output:
  File "/home/neo/.local/lib/python3.6/site-packages/sh.py", line 911, in next
    self.wait()
  File "/home/neo/.local/lib/python3.6/site-packages/sh.py", line 841, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/neo/.local/lib/python3.6/site-packages/sh.py", line 865, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /home/neo/code/siva-android/v1.1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/configure --host=arm-linux-androideabi --build=x86_64-pc-linux-gnu --enable-shared --enable-ipv6 ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no --without-ensurepip ac_cv_little_endian_double=yes --prefix=/usr/local --exec-prefix=/usr/local --with-openssl=/home/neo/code/siva-android/v1.1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/openssl/armeabi-v7a__ndk_target_21/openssl1.1

Sorry for bothering you repeatedly. But this is my first app for android and I am trying to learn the issues. I am really grateful for the advice and help that you are providing.

Thanks in advance.

Shoumik Das

unread,
Nov 17, 2020, 8:30:33 AM11/17/20
to Kivy users support
Update: I changed the requirements from requirements = python3==3.6.9,kivy,android,kivmob,jnius,mysql_connector,pysftp,tweepy,openssl to 
requirements = python3,kivy,android,kivmob,jnius,mysql_connector,pysftp,tweepy,openssl

The app now compiled into an apk which means that the version specific input of python3==3.6.9 was causing the issue. What is the correct way of specifying a specific version of Python to ensure code compatibility?

Thanks

Shoumik Das

unread,
Nov 17, 2020, 11:53:08 AM11/17/20
to Kivy users support
So I ran the apk with the following command: buildozer -v android debug deploy run logcat > my_log.txt

The apk gets generated but it does not get pushed/deployed to my phone. The phone has developer mode turned on.

Attaching logcat output for reference.

Thanks
my_log.txt

planckp...@gmail.com

unread,
Nov 17, 2020, 12:08:06 PM11/17/20
to Kivy users support
The technique for specifying the python (or any package) version is correct. But its not clear to me that 3.6.9 would be helpful, thought I understand it is the desktop version. See next paragraph.

Buildozer does not build an apk containing the installed Python or any of the desktop installed packages. It downloads everything it needs to put in an apk, and defaults to Python 3.8. There are so many moving parts it is probably not a good idea to change this, though some people seem to use 3.7.x successfully. But I wouldn't, I do suggest using kivy==2.0.0rc3

First I suggest first building Hello World with the default buildozer.spec so you can see that the whole thing works. Any issues are then about changes in your control, not about some incomprehensible pile of software.

FYI you don't need android, jnius, openssl in the requirements, these are added by default. Also while you are making changes to the .spec it is a good idea to do a 'buildozer appclean' after the change.

I see your next post, if it is quick and obvious I will respond soon; otherwise response will be much later today.

planckp...@gmail.com

unread,
Nov 17, 2020, 12:17:10 PM11/17/20
to Kivy users support
# Cwd None List of devices attached
<there should be a line here>
# Application pushed.

The debugger is not seeing the phone.  Usual causes:
Is USB debugging on in the phone?
Is the USB cable a power only cable?
Is buildozer running in a VM that can't see a physical USB port?

Shoumik Das

unread,
Nov 18, 2020, 8:53:59 AM11/18/20
to Kivy users support
Hi! I tried all your suggestions. here are my findings:

USB
1. The USB cable is meant for both charging and data transfer. Still, to be sure, I changed and used a new data cable.
2. Developer mode and USB debugging are both turned ON.
3. USB mode is set to file transfer

Case A

1. Used the custom buildozer spec: requirements = python3,kivy==2.0.0rc3,kivmob,mysql_connector,pysftp,tweepy
2. A popup message on the device for trusted source was duly accepted. APK compiled but did not get pushedinto the device.
3. Transferred the APK through Google drive and installed it on the phone. The app crashed after the initial Kivy splash screen.
4. spec file and logcat file are attached (SIVA).

Case B

1. Used the default buildozer spec: requirements = python3,kivy
2. APK got successfully compiled and deployed on the device.
3. It was a simple hello world app with a label.
4. spec file and logcat file are attached (SIVA).

I went through the logcat file for SIVA. Came across a device error which prevented the transfer but nothing much apart from that. Could you please take a look at the file and advise?

Thanks in advance.

hello_buildozer.spec
siva_log.txt
siva_buildozer.spec
helloworld_log.txt

planckp...@gmail.com

unread,
Nov 18, 2020, 12:10:13 PM11/18/20
to Kivy users support
List of devices attached
ZY3227ZQX7 unauthorized

I don't know, but that 'unauthorized' is strange.

There is usually some one time 'accept' dialog on the phone, was that ignored?

If that is not it, I have no suggestion.

Shoumik Das

unread,
Nov 18, 2020, 12:42:17 PM11/18/20
to Kivy users support
I did accept the one-time dialog box. I am doing a rebuild right now, even as we speak, with the default buildozer specs  but with the actual code that I have been trying to compile so long. I shall post the updates here once it is ready. It may take a bit of time.
Message has been deleted

Shoumik Das

unread,
Nov 19, 2020, 3:03:11 AM11/19/20
to Kivy users support
Hi. I finally got a logcat output on a different android device. Attached the logcat output. Below is an excerpt:

List of devices attached
5200bb9b4b634663 device

# Deploy on 5200bb9b4b634663
# Run '/home/neo/.buildozer/android/platform/android-sdk/platform-tools/adb install -r "/home/neo/code/siva-android/v1.1/bin/siva-0.1-armeabi-v7a-debug.apk"'
# Cwd /home/neo/.buildozer/android/platform
Performing Streamed Install
Success
# Application pushed.
# Run on 5200bb9b4b634663
# Run '/home/neo/.buildozer/android/platform/android-sdk/platform-tools/adb shell am start -n org.test.siva/org.kivy.android.PythonActivity -a org.kivy.android.PythonActivity'
# Cwd /home/neo/.buildozer/android/platform
Starting: Intent { act=org.kivy.android.PythonActivity cmp=org.test.siva/org.kivy.android.PythonActivity }
# Application started.
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.0.5 (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 /home/neo/.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-8-openjdk-amd64/jre/bin/keytool
# Run '/home/neo/.buildozer/android/platform/android-sdk/platform-tools/adb logcat '
# Cwd /home/neo/.buildozer/android/platform
--------- beginning of crash
11-16 09:19:19.961  2803 29315 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 29315 (Preview3AAThrea), pid 2803 (prov...@3.0-se)
11-16 09:19:20.044 31254 31254 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-16 09:19:20.045 31254 31254 F DEBUG   : Build fingerprint: 'samsung/m10ltedd/m10lte:10/QP1A.190711.020/M105FDDU3CTI3:user/release-keys'
11-16 09:19:20.045 31254 31254 F DEBUG   : Revision: '4'
11-16 09:19:20.045 31254 31254 F DEBUG   : ABI: 'arm'
11-16 09:19:20.047 31254 31254 F DEBUG   : Timestamp: 2020-11-16 09:19:20+0530
11-16 09:19:20.047 31254 31254 F DEBUG   : pid: 2803, tid: 29315, name: Preview3AAThrea  >>> /vendor/bin/hw/vendor.samsung.hard...@3.0-service <<<
11-16 09:19:20.047 31254 31254 F DEBUG   : uid: 1047
11-16 09:19:20.047 31254 31254 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
11-16 09:19:20.048 31254 31254 F DEBUG   : Cause: null pointer dereference
11-16 09:19:20.048 31254 31254 F DEBUG   :     r0  00000000  r1  00000000  r2  00000001  r3  00000000
11-16 09:19:20.048 31254 31254 F DEBUG   :     r4  ed439a80  r5  00000000  r6  00000001  r7  e5870058
11-16 09:19:20.048 31254 31254 F DEBUG   :     r8  ee41f300  r9  ed439a80  r10 f064d260  r11 e5870060
11-16 09:19:20.048 31254 31254 F DEBUG   :     ip  ef83863c  sp  e58681a0  lr  ef7ab3cb  pc  ef7ab3cc
11-16 09:19:20.068 31254 31254 F DEBUG   : 
11-16 09:19:20.068 31254 31254 F DEBUG   : backtrace:
11-16 09:19:20.068 31254 31254 F DEBUG   :       #00 pc 0006a3cc  /vendor/lib/libexynoscamera3.so (android::ExynosCameraFrame::getFrameDoneFirstEntity(unsigned int)+12) (BuildId: a9243cc5d0a5792ad1baf4e7cb2b99ed)
11-16 09:19:20.069 31254 31254 F DEBUG   :       #01 pc 000be51f  /vendor/lib/libexynoscamera3.so (android::ExynosCamera3::m_handlePreviewFrame(android::ExynosCameraFrame*, int)+146) (BuildId: a9243cc5d0a5792ad1baf4e7cb2b99ed)
11-16 09:19:20.069 31254 31254 F DEBUG   :       #02 pc 000be2af  /vendor/lib/libexynoscamera3.so (android::ExynosCamera3::m_previewStreamFunc(android::ExynosCameraFrame*, int)+150) (BuildId: a9243cc5d0a5792ad1baf4e7cb2b99ed)
11-16 09:19:20.069 31254 31254 F DEBUG   :       #03 pc 000b22c7  /vendor/lib/libexynoscamera3.so (android::ExynosCamera3::m_previewStream3AAPipeThreadFunc()+42) (BuildId: a9243cc5d0a5792ad1baf4e7cb2b99ed)
11-16 09:19:20.069 31254 31254 F DEBUG   :       #04 pc 0006f9c1  /vendor/lib/libexynoscamera3.so (ExynosCameraThread<android::FrameWorker>::threadLoop()+22) (BuildId: a9243cc5d0a5792ad1baf4e7cb2b99ed)
11-16 09:19:20.069 31254 31254 F DEBUG   :       #05 pc 0000d8d9  /system/lib/vndk-sp-29/libutils.so (android::Thread::_threadLoop(void*)+320) (BuildId: 24ba4e12e5e4e09975ba55474dd65466)
11-16 09:19:20.069 31254 31254 F DEBUG   :       #06 pc 000a7d17  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: 9629be880fb61625a90b250575ed6bc7)
11-16 09:19:20.069 31254 31254 F DEBUG   :       #07 pc 00061127  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: 9629be880fb61625a90b250575ed6bc7)
--------- beginning of system
11-19 12:23:00.136  4744  4897 D SamsungAlarmManager: Expired : 4
11-19 12:23:00.137  4744  4897 V SamsungAlarmManager: Sending to uid : 1000 listener=android.app.AlarmManager$ListenerWrapper@6b50e4d


samsungm20_log.txt

planckp...@gmail.com

unread,
Nov 19, 2020, 11:57:49 AM11/19/20
to Kivy users support
with Hello World ?

Shoumik Das

unread,
Nov 19, 2020, 12:03:08 PM11/19/20
to kivy-...@googlegroups.com
No. The error comes with my Kivy program which runs fine on Linux. The hello world app runs just fine. I am wondering if there is any issue with rendering since my app uses canvas to generate coloured screens. Could sdl2 or any other component be causing the issue?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ef324586-44e0-4df2-9dd5-2b63d5069389n%40googlegroups.com.

planckp...@gmail.com

unread,
Nov 19, 2020, 12:34:27 PM11/19/20
to Kivy users support
Always assume your actions create the issue, the question become what did I do that I didn't understand? That should help to narrow the issue down.

The error is 11-16 09:19:20.048 31254 31254 F DEBUG   : Cause: null pointer dereference
The error is coming from Android, this is usually caused by a system call that is called at the wrong time, or with the wrong data. In this case apparently no data. Pretty hard to do from Python, but it is possible.

Could sdl2 or any other component be causing the issue?
Guessing is mostly a waste of time, think about testing.

Find a clear symptom of the error is using print statements, or cutting sections out of the app.

Shoumik Das

unread,
Nov 19, 2020, 1:06:22 PM11/19/20
to kivy-...@googlegroups.com
You are absolutely correct. There is something in my code which is causing the issue. The problem is that my code does not show any error or warning. It runs perfectly fine and I have done quite a bit of testing to cover all use case scenarios.

It has multiple screens and uses a couple of global variables which are all initialised at the start of the program.

The program starts by loading a coloured login screen with a single button. Since the app is crashing after the splash screen, it indicates that the program is not able to load even the first login screen.

I will create a small and simple app with a couple of screens to see if it works or crashes with the same error. I will post my findings here.

Thanks


planckp...@gmail.com

unread,
Nov 19, 2020, 3:25:05 PM11/19/20
to Kivy users support
As I understand it the code is not portable.  There is no clear error message because it is Android that is complaining, not Python.

One way that can happen is by not following the the Kivy life cycle https://kivy.org/doc/stable/guide/basic.html#kivy-app-life-cycle
One way to ignore the life cycle is with global variables. Just not good style, but you can usually get away with static constants. However anything that makes a system call to initialize the variable will possibly fail horribly. Something to check.
Message has been deleted

Shoumik Das

unread,
Nov 20, 2020, 5:29:08 AM11/20/20
to Kivy users support
I have an interesting observation. I made a really simple Kivy app with 2 screens which transition to one another at the click of a button. There is no global variable, function or null value (None). I am also using a custom Python module to check internet connectivity. The compiled apk works fine on the device when I do not use the custom module. However, it crashes like before when I import and use the Python module. The module is very simple and clean. I have attached the code files for your review. They are very short and shouldn't take much time to go through.

Is there an issue in the way I am using and importing the custom module? The remaining standard Python & Kivy modules are working fine. The checknet custom module uses the requests library. Is there a need to specify it in the requirements of the spec file?

Also, since I am using the default spec file, the android sdk, ndk and api values are all commented out. Should I uncomment them and specify them explicitly?

Thanks in advance
checknet.py

planckp...@gmail.com

unread,
Nov 20, 2020, 12:18:55 PM11/20/20
to Kivy users support
Is there an issue in the way I am using and importing the custom module?
You don't show this, but as long as the life cycle is obeyed it should be ok. Don't initialize a global with is_connected()

The checknet custom module uses the requests library. Is there a need to specify it in the requirements of the spec file?
Yes, I expect so. But in this case you will see an error from Python. Something else is preempting that error. Try changing the except to:

        except Exception as e:
            print('======== ' + str(e))
And look in the logcat for ========

I have another priority and may be giving very little attention this group for a few days, if I don't respond it is not because I am ignoring you.

Shoumik Das

unread,
Nov 20, 2020, 1:39:12 PM11/20/20
to Kivy users support
I understand your priorities and I am grateful for the response and suggestions that I am getting. I am new to Kivy; been learning it for the last several months. It is a fantastic framework but my inability to compile a working apk for Android is holding me back. I am trying my best to troubleshoot but I don't have much experience. I am not using any global variable in the test code. Following is my main.py:

from kivy.config import Config
# Config.set should be used before importing any other Kivy module.
Config.set('kivy','window_icon','images/sivalogo1.png')
# Config set for resizing image button
Config.set('graphics', 'resizable', True)
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.screenmanager import ScreenManager, Screen, CardTransition
from kivy.uix.button import Button
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.uix.actionbar import ActionBar, ActionItem
from kivy.uix.textinput import TextInput
from kivy.properties import NumericProperty, StringProperty, ObjectProperty
from kivy.uix.dropdown import DropDown
from kivy.uix.popup import Popup
from kivy.uix.scrollview import ScrollView
import os
import checknet as cn


class ImageButton(ButtonBehavior, Image):
pass


class CustomActionButton(ImageButton, ActionItem):
pass


class SivaLoginScreen(Screen):
def twitter_authentication(self):
net=cn.is_connected()
if net:
App.get_running_app().root.current='status_screen'
App.get_running_app().root.transition.direction='left'
else:
pass


class SivaStatusScreen(Screen):
def to_statusscreen(self):
App.get_running_app().root.current='status_screen'
App.get_running_app().root.transition.direction='left'

def to_accountsscreen(self):
pass

def to_botscreen(self):
pass

def to_termsscreen(self):
pass

def to_logout(self):
App.get_running_app().root.current='login_screen'
App.get_running_app().root.transition.direction='right'

def new_status_entry(self):
pass

def load_status_records(self):
pass


class SivaScreenManager(ScreenManager):
pass


class SivaApp(App):
def build(self):
# Initialize root widget
# Screen Manager Instance
ssm=SivaScreenManager(transition=CardTransition())
# Login Screen Instance
sls=SivaLoginScreen()
# Status Screen Instance
sss=SivaStatusScreen()
# Create the widget tree. Screen Manager is the root widget.
ssm.add_widget(sls)
ssm.add_widget(sss)
return ssm


if __name__ == '__main__':
# Run application
SivaApp().run()

planckp...@gmail.com

unread,
Nov 20, 2020, 3:07:13 PM11/20/20
to Kivy users support
A reminder: You can compile a working apk, just not this one.

Also consider commenting the two Config.set, because I have not tried to figure out what they mean in the Android context.

Shoumik Das

unread,
Nov 21, 2020, 10:27:12 AM11/21/20
to Kivy users support
The only working apk that I have got is that of a simple hello world, lol!   :)  Every thing else failed so far. I created a small new program with two simple screens only for testing and even that is crashing. As per your latest recommendations, I commented out the config statements from my python code and also included requests in the requirements section. It still failed with the same error. Here is the latest logcat output:


--------- beginning of crash
11-16 09:19:19.961  2803 29315 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 29315 (Preview3AAThrea), pid 2803 (prov...@3.0-se)
11-16 09:19:20.044 31254 31254 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-16 09:19:20.045 31254 31254 F DEBUG   : Build fingerprint: 'samsung/m10ltedd/m10lte:10/QP1A.190711.020/M105FDDU3CTI3:user/release-keys'
11-16 09:19:20.045 31254 31254 F DEBUG   : Revision: '4'
11-16 09:19:20.045 31254 31254 F DEBUG   : ABI: 'arm'
11-16 09:19:20.047 31254 31254 F DEBUG   : Timestamp: 2020-11-16 09:19:20+0530
11-16 09:19:20.047 31254 31254 F DEBUG   : pid: 2803, tid: 29315, name: Preview3AAThrea  >>> /vendor/bin/hw/vendor.samsung.hard...@3.0-service <<<
11-16 09:19:20.047 31254 31254 F DEBUG   : uid: 1047
11-16 09:19:20.047 31254 31254 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
11-16 09:19:20.048 31254 31254 F DEBUG   : Cause: null pointer dereference

Where is this null pointer coming from? I am clueless. I am using all standard Python modules, there is no global variable, no global function, no system call or use of None data type.

What should be my way forward? If I can get a simple test program (apart from hello world) to run, I would consider this a success.

Thanks for your patience.

Shoumik Das

unread,
Nov 21, 2020, 11:08:16 AM11/21/20
to Kivy users support
I am attaching the full code of the test program with fonts and images and logcat output for your reference.
screens.zip

planckp...@gmail.com

unread,
Nov 21, 2020, 12:03:57 PM11/21/20
to Kivy users support
Sorry I do not have the resources to debug your app for you. You already know what to do; either cut until it is not broken, or start from something working and add step by step until it breaks.

Where is this null pointer coming from? 
That of course is the question. It is presumably a symptom of abuse of Android.  

Shoumik Das

unread,
Nov 21, 2020, 12:41:53 PM11/21/20
to kivy-...@googlegroups.com
I will continue to try to debug. I narrowed it down to a custom module import but cannot find any further clue, especially when the code works fine on my desktop.

Nevertheless, thank you for your time and guidance. It has helped me understand the debugging process.

Thanks


planckp...@gmail.com

unread,
Nov 21, 2020, 2:56:43 PM11/21/20
to Kivy users support
One different thing to try. Maybe the issue is in the .spec ? Start from a new one don't make any changes unless you get a logcat message say some error (you will see one for requests if that exception doesn't hide it, and another for internet permission, after that I don't know).

Shoumik Das

unread,
Nov 21, 2020, 11:09:29 PM11/21/20
to kivy-...@googlegroups.com
Should I activate the lines for the android SDK, ndk and api versions? In the default spec file, they are all commented out.

planckp...@gmail.com

unread,
Nov 22, 2020, 11:43:52 AM11/22/20
to Kivy users support
No don't change those. We want to recreate the Hello World state.

Shoumik Das

unread,
Nov 24, 2020, 2:54:32 AM11/24/20
to Kivy users support
The app crashed yet again. Default buildozer spec. Not a single character changed inside the file. Same error on device. On a different attempt, I tried compiling with requirements: python3==3.7 as well but the apk compile failed. Currently clueless. :(

Shoumik Das

unread,
Nov 24, 2020, 10:42:36 AM11/24/20
to kivy-...@googlegroups.com
I have been digging around. Is it necessary to specify the custom Python modules (the ones that I have developed) in the buildozer spec file. If yes, how do I do it?

You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/1BW9rhfGG2Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e57a9d25-286a-497c-b469-6109213355a7n%40googlegroups.com.

planckp...@gmail.com

unread,
Nov 24, 2020, 12:32:19 PM11/24/20
to Kivy users support
As long as the modules you wrote are in the same folder as main.py (as files or folders) Python will find them. The requirements (in part) says download these with pip during the Android build (which is also what was done on the desktop)

Shoumik Das

unread,
Nov 25, 2020, 1:35:45 PM11/25/20
to Kivy users support
All the modules are in the same folder as main.py. Any suggestions on the next steps? The app crashes whenever I import a custom module. Is there anything wrong in the way I am defining the module? Does it have to be registered/defined with Kivy in any way?

Thanks

planckp...@gmail.com

unread,
Nov 25, 2020, 2:37:36 PM11/25/20
to Kivy users support
I thought Elliot had some good suggestions in another thread. I see .kv and my eyes glaze over, so I'm no help with that.

He pointed out that requests must not be on the UI thread. We can get away with it on a desktop because the OS is multi tasking, and so hides the issue. There is some package he likes, see that other thread. I just put requests in a Python thread. Either way the result will be asynchronous to the UI.

I get the search for a magic bullet (somebody must have one!), but whatever is the issue it is not familiar to anybody reading/posting here or on Github.

Except, I just remembered this, the description is the same but the case is a lot simpler.
I have no idea if it is related, but since we know Hello World builds there - it might (or not?) be informative to see if you can build this example.

planckp...@gmail.com

unread,
Nov 25, 2020, 4:32:17 PM11/25/20
to Kivy users support
I tried that example and after fixing the .spec it ran fine.

Shoumik Das

unread,
Nov 26, 2020, 6:51:39 AM11/26/20
to Kivy users support
Hi there! I am trying to evaluate the code change options suggested by Elliot in another thread. In the meantime, I checked the link that you had shared and used the following requirements in the default spec file:

requirements = python3,kivy,requests,bs4,urllib3,chardet,idna

The apk compiled but crashed yet again on the device. In that particular user's case, the error/traceback clearly points to a missing requirement: 11-25 11:16:26.341 16591 16624 I python  :  ModuleNotFoundError: No module named 'urllib3'

But, in my case, the error is very vague: null pointer dereference

The only clue that I have is about the point of breaking: The app crashes whenever a custom Python module is imported.

Thanks

planckp...@gmail.com

unread,
Nov 26, 2020, 11:59:22 AM11/26/20
to Kivy users support
I wondered if the other case was the same, but it was not the same, it just had a similar but misdiagnosed symptom.

Nobody can guess what this is. Randomly trying stuff only works if we have enough monkeys. I can only suggest the same things:

1) change that exception code,  see if you get a better message, you want to see 'Traceback' in the logcatfile.
2) the usual debugging technique, keep cutting the app down, demonstrate the issue with a very small example and a buildozer.spec with minimal change. Like the other post get the .py to less than 20 lines including any .kv  . Then perhaps we can understand.

Shoumik Das

unread,
Nov 26, 2020, 1:22:46 PM11/26/20
to Kivy users support
I will keep trying and keep this thread posted. I am not giving up!!!

Shoumik Das

unread,
Nov 28, 2020, 3:33:30 AM11/28/20
to Kivy users support
Hi. I changed the Python code to make it event driven with the UrlRequest module instead of requests and the program is now working as intended on my desktop. However, when I compiled it into an apk, it crashed on launch. After going through the logcat output, I found the following error: open failed: EACCES (Permission denied). I added the following permissions (READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE,MANAGE_DOCUMENTS,MANAGE_EXTERNAL_STORAGE) to the spec file (default sdk, ndk and api) and the apk stopped crashing. The application launched but it was unable to detect any active internet connection. This is my latest permissions setting in the buildozer spec file.

android.permissions = INTERNET,ACCESS_NETWORK_STATE,ACCESS_WIFI_STATE,CHANGE_WIFI_STATE,CHANGE_WIFI_MULTICAST_STATE,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE,MANAGE_DOCUMENTS,MANAGE_EXTERNAL_STORAGE,READ_PHONE_STATE

As a result, the app now launches on the Android (does not crash) but it does not move to the next screen because it does not detect any active internet connection.

I guess it has something to do with the correct android permissions because the code runs fine on my desktop. The open failed: EACCES (Permission denied) error is still present in my logcat output. Am I missing any permission or do I need to specifically set any android sdk, ndk and api version?

Thanks in advance

Shoumik Das

unread,
Nov 28, 2020, 9:38:08 AM11/28/20
to Kivy users support
Attaching the logcat output for reference in case I missed the actual error.
my_log.zip

Shoumik Das

unread,
Nov 28, 2020, 11:18:07 PM11/28/20
to Kivy users support
The issue is now resolved. Steps taken to resolve the issue:

1. Removed the requests module and used UrlRequest instead.
2. Added Android permissions inside the main Python file.
3. Added necessary permissions in the Buildozer spec file.

Thanks a lot for the suggestions and valuable advice.

Reply all
Reply to author
Forward
0 new messages