Building Panda on Android


#62

Hi, Here is what I call and the answer:

localhost:~$ ./dev/panda3d/panda/src/android/run_python.sh /sdcard/Documents/prj/p3d/test.py

Starting: Intent { act=android.intent.action.VIEW dat=file:///storage/emulated/0/Documents/prj/p3d/test.py flg=0x8003 cmp=org.panda3d.sdk/org.panda3d.android.PythonActivity (has extras) }

/sdcard is NOT a physical sdcard. It is the /storage/emulated/0 directory of termux.


#63

It is worth it to set up adb logcat to get the actual log output from Panda3D, otherwise we’re just guessing at what the problem might be.


#64

I have a logcat log.
But as a new user in this forum I am not allowed to upload the zpped logfile. I could copy paste it here. But it is a long post then :slight_smile:


#65
--------- beginning of main
03-15 14:54:45.993 12780 12780 V AudioManager: playSoundEffect   effectType: 0
03-15 14:54:45.996 12780 12780 D HwRTBlurUtils: check blur style for HwToast-Toast, themeResId : 0x7f0a0006, context : com.termux.app.TermuxActivity@9b8d00c, Nhwext : 6, get Blur : disable with , android.graphics.drawable.NinePatchDrawable@bc8cb1d
03-15 14:54:46.034 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
--------- beginning of system
03-15 14:54:46.041 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =false) (mNativeObject  =0)/@0x1e024de,viewVisibility is0
03-15 14:54:46.057 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b44e1d000)/@0x1e024de,relayoutResult is7
03-15 14:54:46.058 12780 12780 W ViewRootImpl[Toast]: EGLdebug Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b44e1d000)/@0x1e024de
03-15 14:54:46.060 12780 12805 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
03-15 14:54:46.060 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:48.008 12780 12805 W libEGL  : EGLNativeWindowType 0x7b44e1d010 disconnect failed
03-15 14:54:49.347 12780 12785 I zygote64: Do partial code cache collection, code=124KB, data=78KB
03-15 14:54:49.348 12780 12785 I zygote64: After code cache collection, code=124KB, data=78KB
03-15 14:54:49.348 12780 12785 I zygote64: Increasing code cache capacity to 512KB
03-15 14:54:49.359 12780 12780 V AudioManager: playSoundEffect   effectType: 0
03-15 14:54:49.362 12780 12780 D HwRTBlurUtils: check blur style for HwToast-Toast, themeResId : 0x7f0a0006, context : com.termux.app.TermuxActivity@9b8d00c, Nhwext : 6, get Blur : disable with , android.graphics.drawable.NinePatchDrawable@84d9daf
03-15 14:54:49.398 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:49.404 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =false) (mNativeObject  =0)/@0x8e065cb,viewVisibility is0
03-15 14:54:49.418 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b44e1d000)/@0x8e065cb,relayoutResult is7
03-15 14:54:49.418 12780 12780 W ViewRootImpl[Toast]: EGLdebug Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b44e1d000)/@0x8e065cb
03-15 14:54:49.423 12780 12805 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
03-15 14:54:49.430 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:51.376 12780 12805 W libEGL  : EGLNativeWindowType 0x7b44e1d010 disconnect failed
03-15 14:54:54.249 12780 12780 V AudioManager: playSoundEffect   effectType: 0
03-15 14:54:54.252 12780 12780 D HwRTBlurUtils: check blur style for HwToast-Toast, themeResId : 0x7f0a0006, context : com.termux.app.TermuxActivity@9b8d00c, Nhwext : 6, get Blur : disable with , android.graphics.drawable.NinePatchDrawable@6fe0333
03-15 14:54:54.282 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:54.288 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =false) (mNativeObject  =0)/@0xd2ab21c,viewVisibility is0
03-15 14:54:54.303 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b44e1d000)/@0xd2ab21c,relayoutResult is7
03-15 14:54:54.304 12780 12780 W ViewRootImpl[Toast]: EGLdebug Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b44e1d000)/@0xd2ab21c
03-15 14:54:54.309 12780 12805 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
03-15 14:54:54.310 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:56.266 12780 12805 W libEGL  : EGLNativeWindowType 0x7b44e1d010 disconnect failed
03-15 14:54:56.915 25828 25828 I appproc : CLASSPATH=/data/data/com.termux/files/usr/libexec/termux-am/am.apk
03-15 14:54:56.915 25828 25828 I appproc : Command=/system/bin/app_process / com.example.termuxam.Am start --activity-clear-task -n org.panda3d.sdk/org.panda3d.android.PythonActivity --user 0 --es org.panda3d.OUTPUT_URI tcp://127.0.0.1:12345 --grant-read-uri-permission --grant-write-uri-permission file:///storage/emulated/0/Documents/prj/p3d/test.py 
03-15 14:54:56.915 25828 25828 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10219 <<<<<<
03-15 14:54:56.917 25828 25828 I AndroidRuntime: readDownloadBoosterConfig: 'false'
03-15 14:54:56.917 25828 25828 I cutils-trace: atrace_init_once, trace_marker_path = /sys/kernel/debug/tracing/trace_marker
03-15 14:54:56.995 25828 25828 I /system/bin/app_process: Reinit property: dalvik.vm.checkjni= false
03-15 14:54:57.001 25828 25828 V HwFrameworkFactory: : successes to get AllImpl object and return....
03-15 14:54:57.012 25828 25828 I HWSERVICES: hwnative_get_component_register:libdrmbitmap,JNI
03-15 14:54:57.023 25828 25828 E Zygote  : register_com_android_internal_os_Zygote num = 0
03-15 14:54:57.035 25828 25828 D AndroidRuntime: Calling main entry com.example.termuxam.Am
03-15 14:54:57.077 25828 25828 D AndroidRuntime: Shutting down VM
03-15 14:54:57.154 12780 12805 W libEGL  : EGLNativeWindowType 0x7b473f5010 disconnect failed
03-15 14:54:57.279 12780 12780 D ActivityThread: Remove activity client record, r= ActivityRecord{67635c2 token=android.os.BinderProxy@a08bf3f {com.termux/com.termux.app.TermuxActivity}} token= android.os.BinderProxy@a08bf3f
03-15 14:54:58.435 12780 12780 D HwCust  : Create obj success use class android.app.HwCustActivityImpl
03-15 14:54:58.437 12780 12780 D HwCust  : Create obj success use class android.app.HwCustHwWallpaperManagerImpl
03-15 14:54:58.439 12780 12780 V ActivityThread: ActivityThread,callActivityOnCreate
03-15 14:54:58.441 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
03-15 14:54:58.441 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
03-15 14:54:58.442 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
03-15 14:54:58.442 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
03-15 14:54:58.442 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
03-15 14:54:58.442 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
03-15 14:54:58.442 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
03-15 14:54:58.442 12780 12780 D CubicBezierInterpolator: CubicBezierInterpolator  mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
03-15 14:54:58.444 12780 12780 D HwRTBlurUtils: check blur style for HwPhoneWindow, themeResId : 0x7f0a0006, context : com.termux.app.TermuxActivity@c0df187, Nhwext : 0, get Blur : disable with , null
03-15 14:54:58.448 12780 25936 I MediaExtractor: Create (null)
03-15 14:54:58.448 12780 25936 W MediaExtractor: creating media extractor in calling process
03-15 14:54:58.450 12780 12780 D ActivityThread: add activity client record, r= ActivityRecord{6c44a95 token=android.os.BinderProxy@73dddc6 {com.termux/com.termux.app.TermuxActivity}} token= android.os.BinderProxy@73dddc6
03-15 14:54:58.451 12780 25936 W MediaExtractor: uid 10219.  not using HwExtendedExtractor 
03-15 14:54:58.451 12780 25936 I MediaExtractor: content 'application/ogg' with conf 0.20
03-15 14:54:58.451 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:58.463 12780 25938 I OMXClient: Treble IOmx obtained
03-15 14:54:58.468 12780 25938 I ACodec  : In onAllocateComponent create compenent, codec name: OMX.google.vorbis.decoder
03-15 14:54:58.468 12780 25938 W HwExtendedUtils: hw configLocalPlayBack err = -2147483648
03-15 14:54:58.469 12780 25938 I HwExtendedCodec: mime is [audio/vorbis] at setAudioFormat
03-15 14:54:58.469 12780 25938 I ACodec  : onStart
03-15 14:54:58.471 12780 12780 D HwRTBlurUtils: check blur style for HwToast-Toast, themeResId : 0x7f0a0006, context : com.termux.app.TermuxActivity@c0df187, Nhwext : 6, get Blur : disable with , android.graphics.drawable.NinePatchDrawable@1534f38
03-15 14:54:58.475 12780 12780 I PressGestureDetector: onAttached begin
03-15 14:54:58.475 12780 12780 I PressGestureDetector: onAttached end
03-15 14:54:58.475 12780 25942 I PressGestureDetector: HiTouch restricted: AboardArea.
03-15 14:54:58.483 12780 25938 W ACodec  : forcing OMX state to Idle when received shutdown in ExecutingState
03-15 14:54:58.524 12780 12805 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
03-15 14:54:58.524 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:58.535 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:58.540 12780 12780 W InputMethodManager: startInputReason = 1
03-15 14:54:58.546 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:54:58.546 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =false) (mNativeObject  =0)/@0x8333202,viewVisibility is0
03-15 14:54:58.559 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b4501a000)/@0x8333202,relayoutResult is7
03-15 14:54:58.559 12780 12780 W ViewRootImpl[Toast]: EGLdebug Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b4501a000)/@0x8333202
03-15 14:54:58.560 12780 12805 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
03-15 14:55:00.477 12780 12805 W libEGL  : EGLNativeWindowType 0x7b4501a010 disconnect failed
03-15 14:55:01.225 12780 12780 V AudioManager: playSoundEffect   effectType: 0
03-15 14:55:01.227 12780 12780 D HwRTBlurUtils: check blur style for HwToast-Toast, themeResId : 0x7f0a0006, context : com.termux.app.TermuxActivity@c0df187, Nhwext : 6, get Blur : disable with , android.graphics.drawable.NinePatchDrawable@26e345f
03-15 14:55:01.253 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:55:01.259 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =false) (mNativeObject  =0)/@0x1c055f1,viewVisibility is0
03-15 14:55:01.277 12780 12780 W ViewRootImpl[Toast]: EGLdebug relayoutWindow Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b4501a000)/@0x1c055f1,relayoutResult is7
03-15 14:55:01.277 12780 12780 W ViewRootImpl[Toast]: EGLdebug Surface isSurface(name=null)  (appName =com.termux) ( mSurfaceControllerIsValid =true) (mNativeObject  =7b4501a000)/@0x1c055f1
03-15 14:55:01.283 12780 12805 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
03-15 14:55:01.290 12780 12805 D OpenGLRenderer:   HWUI Binary is  enabled
03-15 14:55:02.488 12780 12780 D KeyEvent: obtain, mHwFlags=-1


#66

This does not seem to contain Panda3D messages. Did you recover this using adb? If you use logcat on the device itself, you won’t get all messages.

I’ve bumped your trust level in the forums, for what it’s worth, so you should be able to attach logs now.


#67

Hi rdb,

Now I used adb logcat and watched the result.

Here is the error:

03-15 18:10:45.753 10614 10614 W NativeActivity: NativeActivity LoadNativeLibrary("/data/app/org.panda3d.sdk-9IVZl12ALWhlvMye0ekkDg==/lib/arm64/libppython.so") failed: dlopen failed: cannot locate symbol “Py_FileSystemDefaultEncoding” referenced by “/data/app/org.panda3d.sdk-9IVZl12ALWhlvMye0ekkDg==/lib/arm64/libppython.so”…
03-15 18:10:45.753 10614 10614 D AndroidRuntime: Shutting down VM
--------- beginning of crash
03-15 18:10:45.754 10614 10614 E AndroidRuntime: FATAL EXCEPTION: main
03-15 18:10:45.754 10614 10614 E AndroidRuntime: Process: org.panda3d.sdk, PID: 10614
03-15 18:10:45.754 10614 10614 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Unable to load native library “/data/app/org.panda3d.sdk-9IVZl12ALWhlvMye0ekkDg==/lib/arm64/libppython.so”: null
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.NativeActivity.onCreate(NativeActivity.java:194)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7383)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3250)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3405)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.ActivityThread.-wrap12(Unknown Source:0)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:108)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.os.Looper.loop(Looper.java:166)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7523)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
:

I looked up the directory. “/data/app/org.panda3d.sdk-9IVZl12ALWhlvMye0ekkDg==/lib/arm64/libppython.so” is existent.

warm regards

Odo


#68

… Sorry. Missed two lines of the error:

03-15 18:10:45.754 10614 10614 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
03-15 18:10:45.754 10614 10614 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)


#69

Hmm, interesting. Did you compile on termux? Which version of Python did you use?


#70

Yes.
I compiled on Termux with Python 3.7.
I called Makepanda.py with … --target android-21 --use-zlib --no-tiff …

For me it looks like a missing dependency or incompatibility between libraries and Python-Version.

Just right now I am building with --target android-27 to see if that makes a difference.

I will let you know


#71

Hmmm.

Building with --target android-27 makes no difference.

Next thing I tried was:
$pkg install libunwind
and then build with --target android-27 but WITHOUT --use-zlib --no-tiff

Then I can’t even build:

ANNOT LINK EXECUTABLE “built/bin/pzip”: cannot locate symbol “lzma_lzma_preset” referenced by “/data/data/com.termux/files/usr/lib/libtiff.so”…
Storing dependency cache.
Elapsed Time: 34 min 51 sec
The following command returned a non-zero value: built/bin/pzip built/models/misc/Dirlight.egg
Build terminated.

This problem seemed to be solved (uo in this thread) but not for me.
So I can only go with --use-zlib -no-tiff

Next thing I do is updating all packages in termux.

Actually, which Python version did you use? Maybe I must downgrade?


#72

pkg upgrade
pkg update

same result.

unfortunately I don’t know how to downgrade python in termux.

Still I think I am missing an other package…


#73

I’m not really sure. I’ve just been using the Python 3.7.2 that came with Termux.

Note, by the way, that the Android port can can make use of Android’s bitmap APIs, so libtiff isn’t strictly needed to be able to load tiff images.

Maybe they updated a package and we’re missing a library now? I’ll try doing a clean build on my Tegra X1 board and see if I run into any of the same issues.


#74

Py_FileSystemDefaultEncoding is declared in
/data/data/com.termux/files/usr/include/python3.7m/fileobject.h

  • The default encoding used by the platform file system APIs
    If non-NULL, this is different than the default encoding for strings
    */
    PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;

Maybe we have a linker problem or a problem with the library path or the include path when building panda3d for android?


#75

Even more strange. Py_FileSystemDefaultEncodig has only one occurence in the pana sources:

./panda/src/android/python_main.cxx: Py_FileSystemDefaultEncoding = “utf-8”;

I commented this line in the source and rebuilt everything but the error remains.

So the error seeems to be in the termux libraries or in the linker-settings…

But I am not a professional programmer. So at this point I must give up :frowning:


#76

I’m taking a look. It’s just taking me a while to get to it (I also am needing to rebuild because of the libtiff issue, which takes a while).


#77

It’s a problem in the build system. I’ve checked in a fix; use git pull to get the latest changes.

Then, rm built/lib/libppython.so and rebuild.

Don’t forget to revert the change you had made to python_main.cxx first!


#78

rdb, you are my hero :smile:

Everything works perfectly now.

Thank you very much!!