[ ] I have a short, runnable example that reproduces the issue
[ x] I reproduced the problem with the latest development version (p4a.branch = develop)
[ x] I used the grave accent (aka backticks) to format code or logs when appropriated
Versions
Python: 3.9.9
OS: WSL/Android
Kivy: 2.1.0
Cython:
OpenJDK: 13
Description
The p4a service_class_name option allows changing the service base class name, enabling a custom service class implementation. The implementation of the option is here:
So if a custom service base class is used to start a service, we get a run time link error. Because java_org_kivy_android_CustomPythonService_nativeStart() does not exist. See buildozer.spec and log snippets below, where we use the option to replace PythonService with CustomPythonService which has unchanged functionality.
# (str) Full name including package path of the Java class that implements Python Service
# use that parameter to set custom Java class instead of PythonService
android.service_class_name = org.kivy.android.CustomPythonService
# (list) List of Java files to add to the android project (can be java or a
# directory containing the files)
android.add_src =org/kivy/android/CustomPythonService.java
Logs
09-27 16:28:23.517 9923 9944 E AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for void org.kivy.android.CustomPythonService.nativeStart(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) (tried Java_org_kivy_android_CustomPythonService_nativeStart and Java_org_kivy_android_CustomPythonService_nativeStart__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2)
Checklist
p4a.branch = develop
)Versions
Description
The p4a service_class_name option allows changing the service base class name, enabling a custom service class implementation. The implementation of the option is here:
https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/bootstraps/common/build/templates/Service.tmpl.java#L5-L8
One of the required methods in this class is
run()
which in the default implementation callsnativeStart()
. https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonService.java#L178-L187However
nativeStart()
is a JNI method hard coded with the default base class name https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/bootstraps/common/build/jni/application/src/start.c#L359.So if a custom service base class is used to start a service, we get a run time link error. Because
java_org_kivy_android_CustomPythonService_nativeStart()
does not exist. See buildozer.spec and log snippets below, where we use the option to replacePythonService
withCustomPythonService
which has unchanged functionality.The feature was added here https://github.com/kivy/python-for-android/commit/49de42153b137c310b84cd48a57176af08254d53
buildozer.spec
Command:
Spec file:
Logs