pyjnius: App crashes if we use 'org.renpy.android.PythonActivity' in p4a new toolchain

If we use org.renpy.android.PythonActivity (instead new org.kivy.android.PythonActivity) in app built with p4a new toolchain it’ll crash. See this issue for example (there’s also typical log there):

W/PythonActivity(28456): Accessing org.renpy.android.PythonActivity is deprecated and will be removed in a future version. Please switch to org.kivy.android.PythonActivity.
F/art     (28456): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: static jfieldID 0x746c91a0 not valid for class java.lang.Class<org.renpy.android.PythonActivity>
F/art     (28456): art/runtime/check_jni.cc:65]     in call to GetStaticObjectField
F/art     (28456): art/runtime/check_jni.cc:65]     from int org.libsdl.app.SDLActivity.nativeInit(java.lang.Object)
F/art     (28456): art/runtime/check_jni.cc:65] "SDLThread" prio=5 tid=15 Runnable
...

It can be temporary solved by replacing org.renpy.android.PythonActivity with org.kivy.android.PythonActivity everywhere in the code manually or with some dirty patch.

But correct solution would be to fix pyjnius not to crash with org.renpy.android.PythonActivity in p4a new toolchain.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

It worked after changing org.renpy.android to org.kivy.android in the file you mentioned. Should I make a pull request for that? Or is there any reason plyer is still using the old value? Thanks for your help.

Here’s a diff:

diff --git a/plyer/platforms/android/__init__.py b/plyer/platforms/android/__init__.py
index 8fe1263..252f8b4 100644
--- a/plyer/platforms/android/__init__.py
+++ b/plyer/platforms/android/__init__.py
@@ -8,7 +8,7 @@ try:
     from android import config
     ns = config.JAVA_NAMESPACE
 except (ImportError, AttributeError):
-    ns = 'org.renpy.android'
+    ns = 'org.kivy.android'
 
 if 'PYTHON_SERVICE_ARGUMENT' in environ:
     PythonService = autoclass(ns + '.PythonService')

I’m at a loss for this one - it seems to match the example app at https://github.com/kivy/python-for-android/blob/master/testapps/testapp_flask/main.py, which does work for me.

On 10/03/17 18:49, Matous wrote:

Thanks for the answers. I already include |pyjnius|, and import |org.kivy.android.PythonActivity|, but still get an error.

This is the log I get with |p4a adb logcat|:

|I/python ( 4329): import luscinia_android_test as lat I/python ( 4329): File “/sdcard/luscinia/luscinia_android_test.zip/luscinia_android_test.py”, line 3, in <module> I/python ( 4329): File “/data/data/org.example.luscinia/files/lib/python2.7/site-packages/jnius/reflect.py”, line 154, in autoclass I/python ( 4329): c = find_javaclass(clsname) I/python ( 4329): File “jnius/jnius_export_func.pxi”, line 25, in jnius.jnius.find_javaclass (jnius/jnius.c:16608) I/python ( 4329): JavaException: Class not found ‘org/kivy/android/PythonActivity’ |

The actual source code where it crashes reads:

|from jnius import autoclass, cast PythonActivity = autoclass(‘org.kivy.android.PythonActivity’) |

The result with |org.renpy.android.PythonActivity| is the same.

I build the app like this:

|python-for-android apk --private . --dist_name=webview_01 –android-api=15 --ndk-version=r11b –requirements=cherrypy,sqlalchemy,sqlite3,pyjnius –package=org.example.luscinia --name “Luscinia” --permission WRITE_EXTERNAL_STORAGE --permission INTERNET --add-source=luscinia –add-source=unidecode --version=0.26 --port=9371 |

where the environment |webview_01| is built using

|python-for-android create --dist_name=webview_01 --bootstrap=webview –requirements=python2,sqlite3,cherrypy,sqlalchemy,pyjnius |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/pyjnius/issues/249#issuecomment-285752184, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNQm2aIccVG2QzmOhbJ2t5uckMWnwumks5rkZsegaJpZM4LP78X.