pyotherside icon indicating copy to clipboard operation
pyotherside copied to clipboard

Crash on start python on android

Open modos189 opened this issue 8 years ago • 5 comments

Hi. Please help me build python for android. I tried to run this example on your phone: https://github.com/ldanzinger/PyOtherSideForArcGIS/tree/master/01_HelloWorld but after launch, the app closes with error.

If in https://github.com/ldanzinger/PyOtherSideForArcGIS/blob/master/01_HelloWorld/main.qml to delete 29-35 and 45-52 lines, the application starts successfully.

similarly, when you run the example from this repository (pyotherside/examples/qrc). The log error I attached. log.txt

I assumed that the error in the Python and copied binary file python3m on the phone and it turned out that at startup it outputs: Error: only position independent executables (PIE) are supported.

I fixed that Python was compiled with PIE support and run on the phone, but ready apk still app crashes.

Since https://github.com/thp/python3-android is not available, I used this repositories: https://github.com/GRRedWings/python3-android (v3.5) or https://github.com/rave-engine/python3-android (v3.4).

My workflow:

  1. Download and install last sdk (android-sdk_r24.4.1-linux.tgz), ndk (android-ndk-r12b-linux-x86_64.zip) and Qt (qt-opensource-linux-x64-android-5.7.0.run)
  2. git clone https://github.com/GRRedWings/python3-android
  3. in file 'env' installs versions of the sdk and ndk
  4. for PIE: in python3-android/mk/python/VERSION/build.sh after patchs and before ./configure. add bash
  5. make
  6. for PIE: replace all -Xlinker -export-dynamic on -Xlinker -export-dynamic -fPIE -Wl,-pie and exit in terminal for close bash.
  7. cd build/.../lib/ && zip -r pythonlib.zip *
  8. git clone https://github.com/thp/pyotherside.git && copy pythonlib.zip to pyotherside/src
  9. edit pyotherside/python.pri:
QMAKE_LIBS += -L/home/user/python3-android/build/12b-21-arm-linux-androideabi-4.9/lib -lpython3.5m -ldl -lm -lc -lssl -lcrypto
QMAKE_CXXFLAGS += -I/home/user/python3-android/build/12b-21-arm-linux-androideabi-4.9/include/python3.5m/
  1. /home/user/Qt5.7.0/5.7/android_armv7/bin/qmake PYTHON_CONFIG=python3.5-config
  2. make
  3. copy libpyothersideplugin.so and qmldir to /home/user/Qt5.7.0/5.7/android_armv7/qml/io/thp/pyotherside/

If you run as is, on android, the program will fail with an error indicating that not enough python3.5m.so. Fix it:

  1. copy python3.5m.so to /home/user/Qt5.7.0/5.7/android_armv7/lib && chmod 777 /home/user/Qt5.7.0/5.7/android_armv7/lib/python3.5m.so
  2. Open installed QtCreator, open example project, make and deploy on android. And error on running.
  3. Crash application)

I'm use: linux debian amd64 android ndk r12b sdk 25.1.7 Qt5.7.0

and android 5.1.1

modos189 avatar Jul 11 '16 17:07 modos189

Today I repeated the steps from the documentation, including use API 14. I used to miss this point, so they had to fix PIE. But at API 14, the application crashes when calling python.

Please tell me, what am I doing wrong.

modos189 avatar Sep 04 '16 18:09 modos189

Have you figured out how to use PyOtherSide on Android? Adding PIE doesn't work, it tries to link the app against pthread which isn't available under Android.

ksiazkowicz avatar Oct 15 '18 14:10 ksiazkowicz

I got error dlopen failed: library "libpython3.9.so.1.0" not found when trying this project. How can I use libpython3.9.so only?

edips avatar Nov 17 '19 01:11 edips

You can usually just create a symlink or rename the library.

thp avatar Nov 21 '19 19:11 thp

I renamed the library before and I got the same error :/

edips avatar Mar 08 '20 07:03 edips