Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on start python on android #71

Open
modos189 opened this issue Jul 11, 2016 · 5 comments
Open

Crash on start python on android #71

modos189 opened this issue Jul 11, 2016 · 5 comments

Comments

@modos189
Copy link

modos189 commented Jul 11, 2016

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
Copy link
Author

modos189 commented Sep 4, 2016

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.

@ksiazkowicz
Copy link

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.

@edips
Copy link

edips commented Nov 17, 2019

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?

@thp
Copy link
Owner

thp commented Nov 21, 2019

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

@edips
Copy link

edips commented Mar 8, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants