question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kchomskicommented, Mar 5, 2017

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')
1reaction
inclementcommented, Mar 10, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

kivy@groups.io | [pyjnius:master] new issue: App crashes if we use ...
If we use org.renpy.android.PythonActivity (instead new org.kivy.android.PythonActivity ) in app built with p4a new toolchain it'll crash.
Read more >
Buildozer Class not found b'org/renpy/android/PythonActivity'
app I /python: Python for android ended. The app ran completely fine on my computer but shows this error when running on Android....
Read more >
python-for-android Documentation
python-for-android is an open source build tool to let you package Python code into standalone android APKs. These can be passed around, ...
Read more >
Kivy app working on PC but not on Android with Buildozer ...
I'm new to coding, learned Python3 to see if I can, and trying to do an Android Application for my ... PythonActivity =...
Read more >
kivy Changelog - pyup.io
Deletes deprecated renpy Python{Activity,Service}.java ... App crashes if we use 'org.renpy.android.PythonActivity' in p4a new toolchain ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found