Building Plyer GPS example for android with python 3 and buildozer

596 views
Skip to first unread message

Piet Stevens

unread,
May 31, 2017, 6:06:20 AM5/31/17
to Kivy users support
I am still struggling to get an apk built with python 3.

With my own skeleton app, I ran into all sorts of problems (see other thread with similar title) so I decided to build the Plyer GPS example.

I am on Ubuntu 16.04, using buildozer 0.34dev and python3.5. I modified the .spec to include the crystax NDK and requirements.

With python3.5 and "buildozer android debug", the logcat has this error (multiple times):
05-31 10:39:20.851 30827 30827 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-31 10:39:20.851 30827 30827 F DEBUG   : Build fingerprint: 'ZTE/P996A01_N/ailsa_ii:7.0/NRD90M/20170128.052618:user/release-keys'
05-31 10:39:20.851 30827 30827 F DEBUG   : Revision: '0'
05-31 10:39:20.851 30827 30827 F DEBUG   : ABI: 'arm'
05-31 10:39:20.852 30827 30827 F DEBUG   : pid: 30551, tid: 30729, name: SDLThread  >>> org.test.gpsexample <<<
05-31 10:39:20.852 30827 30827 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
05-31 10:39:20.856 30827 30827 F DEBUG   : Abort message: 'art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: static jfieldID 0xdc060014 not valid for class java.lang.Class<org.renpy.android.PythonActivity>'
05-31 10:39:20.856 30827 30827 F DEBUG   :     r0 00000000  r1 00007809  r2 00000006  r3 00000008
05-31 10:39:20.856 30827 30827 F DEBUG   :     r4 cd782978  r5 00000006  r6 cd782920  r7 0000010c
05-31 10:39:20.857 30827 30827 F DEBUG   :     r8 00000000  r9 0000000a  sl 0000076e  fp dc0ce100
05-31 10:39:20.857 30827 30827 F DEBUG   :     ip 00000000  sp cd780608  lr e80eeb67  pc e80f13c4  cpsr 20010010
05-31 10:39:20.867 30827 30827 F DEBUG   :
05-31 10:39:20.867 30827 30827 F DEBUG   : backtrace:
05-31 10:39:20.867 30827 30827 F DEBUG   :     #00 pc 0004a3c4  /system/lib/libc.so (tgkill+12)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #01 pc 00047b63  /system/lib/libc.so (pthread_kill+34)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #02 pc 0001d445  /system/lib/libc.so (raise+10)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #03 pc 00018f91  /system/lib/libc.so (__libc_android_abort+34)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #04 pc 000171cc  /system/lib/libc.so (abort+4)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #05 pc 0031b371  /system/lib/libart.so (_ZN3art7Runtime5AbortEPKc+328)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #06 pc 000b50b5  /system/lib/libart.so (_ZN3art10LogMessageD2Ev+1132)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #07 pc 0023a6b5  /system/lib/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1664)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #08 pc 0023a8a7  /system/lib/libart.so (_ZN3art9JavaVMExt9JniAbortVEPKcS2_St9__va_list+58)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #09 pc 000caa5b  /system/lib/libart.so (_ZN3art11ScopedCheck6AbortFEPKcz+46)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #10 pc 000ce389  /system/lib/libart.so (_ZN3art11ScopedCheck16CheckFieldAccessERNS_18ScopedObjectAccessEP8_jobjectP9_jfieldIDbNS_9Primitive4TypeE+104)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #11 pc 000cdfd1  /system/lib/libart.so (_ZN3art8CheckJNI8GetFieldEPKcP7_JNIEnvP8_jobjectP9_jfieldIDbNS_9Primitive4TypeE+520)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #12 pc 000c3ea7  /system/lib/libart.so (_ZN3art8CheckJNI20GetStaticObjectFieldEP7_JNIEnvP7_jclassP9_jfieldID+42)
05-31 10:39:20.867 30827 30827 F DEBUG   :     #13 pc 00039573  /mnt/expand/c6135b0f-4f0c-4eb4-99f1-f1cdd3521c84/user/0/org.test.gpsexample/files/app/crystax_python/site-packages/jnius/jnius.so
05-31 10:39:20.925 30700 30737 I InstalledAppProviderSer: Marking com.android.providers.calendar as installed
05-31 10:39:20.995 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:20.996 30772 30793 E 0:3856116000: platstubs.cpp,Line#1654:NOTIMPL
05-31 10:39:21.060 30772 30793 I ONMJniLibraryLoader: ################################### load modernonandroid end ###################################
05-31 10:39:21.060 30772 30793 I ONMJniLibraryLoader: Complete preload of native libs @135447420 sAreLibrariesLoaded: true

Could not find much about this error by googling.

So then I switched to python2.7 using update-alternatives and "buildozer android_old debug". Now, the apk runs on android (I did not receive any GPS coordinates, but at least the apk starts and shows the user-interface with the button to start the GPS data collection).

Has anyone succeeded in building a runnable apk with python 3 and plyer? Any recommendations?

Thank you,

Piet

Alexander Taylor

unread,
May 31, 2017, 6:02:39 PM5/31/17
to Kivy users support
The error about the jfieldID indicates that the code is incorrectly trying to autoclass org.renpy.android.PythonActivity, when it should be autoclassing org.kivy.android.PythonActivity. This needs fixing in plyer, if it has not already been fixed in master.

I think there is code in plyer to do the right thing if the `android` module is installed, so you can try adding `android` to your requirements line in the buildozer.spec.

Piet Stevens

unread,
Jun 2, 2017, 3:53:13 PM6/2/17
to Kivy users support
Thank you for your continued help. I switched everything back to python3.5.2, switched the ndk to crystax, added android in the requirements and now it works. It also displays the GPS coordinates. Excellent.

.apk size did increase from some 8M to 24M, but ok.

Now on to my own apk.

Can I update the .spec file in the GPS sample in github and add some comments to the README? That may help others in the future.
Reply all
Reply to author
Forward
0 new messages