kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.33k stars 1.85k forks source link

Kivy crashes on Android: ImportError: dlopen failed. #1810

Closed nitanmarcel closed 5 years ago

nitanmarcel commented 5 years ago

Versions

Description

I can't make the app run on my android phone. It works on my pc but on my phone this error comes up: ImportError: dlopen failed: "/data/data/demo.org.rextesterdroid/files/app/_python_bundle/site-packages/kivy/_clock.so" is 64-bit instead of 32-bit

Logs

04-30 11:57:33.349 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libsqlite3.so
04-30 11:57:33.349 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libSDL2_image.so
04-30 11:57:33.350 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libhidapi.so
04-30 11:57:33.350 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libffi.so
04-30 11:57:33.350 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libpython3.7m.so
04-30 11:57:33.350 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libmain.so
04-30 11:57:33.350 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libSDL2_mixer.so
04-30 11:57:33.351 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libSDL2_ttf.so
04-30 11:57:33.351 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libssl1.1.so
04-30 11:57:33.351 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libSDL2.so
04-30 11:57:33.351 16065 16065 V pythonutil: Checking pattern libcrystax\.so against libcrypto1.1.so
04-30 11:57:33.353 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libsqlite3.so
04-30 11:57:33.353 16065 16065 V pythonutil: Pattern libsqlite3\.so matched file libsqlite3.so
04-30 11:57:33.354 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_image.so
04-30 11:57:33.354 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libhidapi.so
04-30 11:57:33.354 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libffi.so
04-30 11:57:33.354 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libpython3.7m.so
04-30 11:57:33.354 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libmain.so
04-30 11:57:33.354 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_mixer.so
04-30 11:57:33.355 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_ttf.so
04-30 11:57:33.355 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libssl1.1.so
04-30 11:57:33.355 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libSDL2.so
04-30 11:57:33.355 16065 16065 V pythonutil: Checking pattern libsqlite3\.so against libcrypto1.1.so
04-30 11:57:33.357 16065 16065 V pythonutil: Checking pattern libffi\.so against libsqlite3.so
04-30 11:57:33.357 16065 16065 V pythonutil: Checking pattern libffi\.so against libSDL2_image.so
04-30 11:57:33.357 16065 16065 V pythonutil: Checking pattern libffi\.so against libhidapi.so
04-30 11:57:33.357 16065 16065 V pythonutil: Checking pattern libffi\.so against libffi.so
04-30 11:57:33.358 16065 16065 V pythonutil: Pattern libffi\.so matched file libffi.so
04-30 11:57:33.358 16065 16065 V pythonutil: Checking pattern libffi\.so against libpython3.7m.so
04-30 11:57:33.358 16065 16065 V pythonutil: Checking pattern libffi\.so against libmain.so
04-30 11:57:33.358 16065 16065 V pythonutil: Checking pattern libffi\.so against libSDL2_mixer.so
04-30 11:57:33.358 16065 16065 V pythonutil: Checking pattern libffi\.so against libSDL2_ttf.so
04-30 11:57:33.359 16065 16065 V pythonutil: Checking pattern libffi\.so against libssl1.1.so
04-30 11:57:33.359 16065 16065 V pythonutil: Checking pattern libffi\.so against libSDL2.so
04-30 11:57:33.359 16065 16065 V pythonutil: Checking pattern libffi\.so against libcrypto1.1.so
04-30 11:57:33.361 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libsqlite3.so
04-30 11:57:33.361 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libSDL2_image.so
04-30 11:57:33.361 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libhidapi.so
04-30 11:57:33.361 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libffi.so
04-30 11:57:33.362 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libpython3.7m.so
04-30 11:57:33.362 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libmain.so
04-30 11:57:33.362 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libSDL2_mixer.so
04-30 11:57:33.362 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libSDL2_ttf.so
04-30 11:57:33.362 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libssl1.1.so
04-30 11:57:33.362 16065 16065 V pythonutil: Pattern libssl.*\.so matched file libssl1.1.so
04-30 11:57:33.363 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libSDL2.so
04-30 11:57:33.363 16065 16065 V pythonutil: Checking pattern libssl.*\.so against libcrypto1.1.so
04-30 11:57:33.364 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libsqlite3.so
04-30 11:57:33.364 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_image.so
04-30 11:57:33.364 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libhidapi.so
04-30 11:57:33.364 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libffi.so
04-30 11:57:33.364 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libpython3.7m.so
04-30 11:57:33.365 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libmain.so
04-30 11:57:33.365 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_mixer.so
04-30 11:57:33.365 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_ttf.so
04-30 11:57:33.365 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libssl1.1.so
04-30 11:57:33.365 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2.so
04-30 11:57:33.366 16065 16065 V pythonutil: Checking pattern libcrypto.*\.so against libcrypto1.1.so
04-30 11:57:33.366 16065 16065 V pythonutil: Pattern libcrypto.*\.so matched file libcrypto1.1.so
04-30 11:57:33.366 16065 16065 V pythonutil: Loading library: sqlite3
04-30 11:57:33.372 16065 16065 V pythonutil: Loading library: ffi
04-30 11:57:33.373 16065 16065 V pythonutil: Loading library: SDL2
04-30 11:57:33.378 16065 16065 V pythonutil: Loading library: SDL2_image
04-30 11:57:33.380 16065 16065 V pythonutil: Loading library: SDL2_mixer
04-30 11:57:33.383 16065 16065 V pythonutil: Loading library: SDL2_ttf
04-30 11:57:33.386 16065 16065 V pythonutil: Loading library: ssl1.1
04-30 11:57:33.389 16065 16065 V pythonutil: Loading library: crypto1.1
04-30 11:57:33.390 16065 16065 V pythonutil: Loading library: python2.7
04-30 11:57:33.394 16065 16065 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/base.apk"],nativeLibraryDirectories=[/data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/lib/arm, /data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libpython2.7.so"
04-30 11:57:33.394 16065 16065 V pythonutil: Loading library: python3.5m
04-30 11:57:33.395 16065 16065 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/base.apk"],nativeLibraryDirectories=[/data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/lib/arm, /data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libpython3.5m.so"
04-30 11:57:33.395 16065 16065 V pythonutil: Loading library: python3.6m
04-30 11:57:33.396 16065 16065 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/base.apk"],nativeLibraryDirectories=[/data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/lib/arm, /data/app/demo.org.rextesterdroid-YrjVyt4GtoR4HsmJb479yw==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libpython3.6m.so"
04-30 11:57:33.396 16065 16065 V pythonutil: Loading library: python3.7m
04-30 11:57:33.403 16065 16065 V pythonutil: Loading library: main
04-30 11:57:33.405 16065 16065 V pythonutil: Failed to load _io.so or unicodedata.so...but that's okay.
04-30 11:57:33.405 16065 16065 V pythonutil: Unsatisfied linker when loading ctypes
04-30 11:57:33.405 16065 16065 V pythonutil: Loaded everything!
04-30 11:57:33.540 16065 16086 I python  : Initializing Python for Android
04-30 11:57:33.540 16065 16086 I python  : Setting additional env vars from p4a_env_vars.txt
04-30 11:57:33.540 16065 16086 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
04-30 11:57:33.540 16065 16086 I python  : /data/user/0/demo.org.rextesterdroid/files/app
04-30 11:57:33.541 16065 16086 I python  : Preparing to initialize python
04-30 11:57:33.542 16065 16086 I python  : _python_bundle dir exists
04-30 11:57:33.542 16065 16086 I python  : calculated paths to be...
04-30 11:57:33.542 16065 16086 I python  : /data/user/0/demo.org.rextesterdroid/files/app/_python_bundle/stdlib.zip:/data/user/0/demo.org.rextesterdroid/files/app/_python_bundle/modules
04-30 11:57:33.544 16065 16086 I python  : set wchar paths...
04-30 11:57:33.607 16065 16086 I python  : Initialized python
04-30 11:57:33.607 16065 16086 I python  : AND: Init threads
04-30 11:57:33.609 16065 16086 I python  : testing python print redirection
04-30 11:57:33.610 16065 16086 I python  : Android path ['.', '/data/user/0/demo.org.rextesterdroid/files/app/_python_bundle/stdlib.zip', '/data/user/0/demo.org.rextesterdroid/files/app/_python_bundle/modules', '/data/user/0/demo.org.rextesterdroid/files/app/_python_bundle/site-packages']
04-30 11:57:33.611 16065 16086 I python  : os.environ is environ({'PATH': '/sbin:/system/sbin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin', 'DOWNLOAD_CACHE': '/data/cache', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'BOOTCLASSPATH': '/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/bouncycastle.jar:/system/framework/apache-xml.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.hidl.base-V1.0-java.jar:/system/framework/android.hidl.manager-V1.0-java.jar:/system/framework/framework-oahl-backward-compatibility.jar:/system/framework/android.test.base.jar:/system/framework/org.ifaa.android.manager.jar:/system/framework/telephony-ext.jar', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar:/system/framework/com.android.location.provider.jar', 'ANDROID_CACHE': '/cache', 'TERMINFO': '/system/etc/terminfo', 'ANDROID_SOCKET_zygote_secondary': '12', 'ANDROID_ENTRYPOINT': 'main.pyc', 'ANDROID_ARGUMENT': '/data/user/0/demo.org.rextesterdroid/files/app', 'ANDROID_APP_PATH': '/data/user/0/demo.org.rextesterdroid/files/app', 'ANDROID_PRIVATE': '/data/user/0/demo.org.rextesterdroid/files', 'ANDROID_UNPACK': '/data/user/0/demo.org.rextesterdroid/files/app', 'PYTHONHOME': '/data/user/0/demo.org.rextesterdroid/files/app', 'PYTHONPATH': '/data/user/0/demo.org.rextesterdroid/files/app:/data/user/0/demo.org.rextesterdroid/files/app/lib', 'PYTHONOPTIMIZE': '2', 'P4A_BOOTSTRAP': 'SDL2', 'PYTHON_NAME': 'python', 'P4A_IS_WINDOWED': 'False', 'P4A_ORIENTATION': 'portrait', 'P4A_NUMERIC_VERSION': 'None', 'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
04-30 11:57:33.611 16065 16086 I python  : Android kivy bootstrap done. __name__ is __main__
04-30 11:57:33.611 16065 16086 I python  : AND: Ran string
04-30 11:57:33.611 16065 16086 I python  : Run user program, change dir and execute entrypoint
04-30 11:57:34.108 16065 16086 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/demo.org.rextesterdroid/files/app/.kivy/logs/kivy_19-04-30_3.txt
04-30 11:57:34.108 16065 16086 I python  : [INFO   ] [Kivy        ] v1.11.0.dev0, git-26fa79c, 20190430
04-30 11:57:34.109 16065 16086 I python  : [INFO   ] [Python      ] v3.7.1 (default, Apr 29 2019, 22:49:16) 
04-30 11:57:34.109 16065 16086 I python  : [Clang 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55
04-30 11:57:34.115 16065 16086 I python  :  Traceback (most recent call last):
04-30 11:57:34.115 16065 16086 I python  :    File "/home/alexandrumarcel/projects/kivy-apps/rextester/.buildozer/android/app/main.py", line 5, in <module>
04-30 11:57:34.115 16065 16086 I python  :    File "/home/alexandrumarcel/projects/kivy-apps/rextester/.buildozer/android/platform/build/build/python-installs/rextesterdroid/kivy/app.py", line 319, in <module>
04-30 11:57:34.116 16065 16086 I python  :    File "/home/alexandrumarcel/projects/kivy-apps/rextester/.buildozer/android/platform/build/build/python-installs/rextesterdroid/kivy/base.py", line 26, in <module>
04-30 11:57:34.117 16065 16086 I python  :    File "/home/alexandrumarcel/projects/kivy-apps/rextester/.buildozer/android/platform/build/build/python-installs/rextesterdroid/kivy/clock.py", line 362, in <module>
04-30 11:57:34.117 16065 16086 I python  :  ImportError: dlopen failed: "/data/data/demo.org.rextesterdroid/files/app/_python_bundle/site-packages/kivy/_clock.so" is 64-bit instead of 32-bit
04-30 11:57:34.117 16065 16086 I python  : Python for android ended.
matham commented 5 years ago

This doesn't seem like a kivy issue, but a py4a issue.

inclement commented 5 years ago

Don't know what has happened here, unless you have set $P4A_kivy_DIR perhaps?

nitanmarcel commented 5 years ago

@inclement Yes, I've set that $P4A_kivy_DIR

inclement commented 5 years ago

@nitanmarcel Aha, in that case I think you're hitting a bug where p4a does not recompile kivy because the setup.py process sees the .so files are already present, and doesn't know that they are for the wrong architecture. I think I'm working around that by deleting kivy/_event.c, which should trigger cython to be re-run without preventing the Kivy install from being used for other stuff.

nitanmarcel commented 5 years ago

@inclement deleted the env variable also the .buildozer folder and the error is still there

inclement commented 5 years ago

Can you do that again, re-run buildozer, and post the full build log?

nitanmarcel commented 5 years ago

@inclement Here is the full console log https://transfer.sh/FqXFs/buildozer.log

nitanmarcel commented 5 years ago

Can you do that again, re-run buildozer, and post the full build log?

After a lot of fights with switching between different versions of p4a and kivy I managed to build using kivy==master . I still have no idea what caused that weird bug and why it's working right now. I will leave this issue open if you need it for future reference.

windowsansiblernew commented 5 years ago

where did you give kivy==master this? in buildozer.spec? i also have the same issue, please help

TechnoLenzer commented 5 years ago

Once I fixed this issue as mentioned above and rebuilt, the 64-bit app crashes upon launch. The logger doesn't specify the error and there's no Traceback, it just says that python-for-android ended. Is there possibly an issue with the imports or would it be with my phone (Huawei P20)?

inclement commented 5 years ago

@TechnoLenzer Please paste the full adb logcat output at the kivy-users mailing list or kivy discord channel.

HelaFaye commented 5 years ago

I just encountered a similar error with android while moving from python2 to python3. Cleaning up after previous builds helps.

TechnoLenzer commented 5 years ago

@inclement The issue wasn't actually anything to do with the change to 64-bit, but it was that the app crashed when it asked for the ACCESS_FINE_LOCATION permission. I didn't really need it so I deleted it from the code.

chavarinbonbyn commented 4 years ago

This fails on a Huawei phone. In my other phones works just fine. This applies for the laptop as well. What could be the issue ?

06-12 19:39:53.261 10723 10762 I python : File "/data/data/org.test.test_buddy.myapp/files/app/view/welcome.kv", line 46, in 06-12 19:39:53.263 10723 10762 I python : on_release: root.open_settings() 06-12 19:39:53.263 10723 10762 I python : File "./controller/welcome.py", line 21, in open_settings 06-12 19:39:53.265 10723 10762 I python : from controller.settings import Settings 06-12 19:39:53.265 10723 10762 I python : ImportError: dlopen failed: library "libpython3.7m.so" not found 06-12 19:39:53.265 10723 10762 I python : Python for android ended.

onsunsl commented 4 years ago

I also encountered same problem.

  File "/home/kivy/test/.buildozer/android/app/schedule/scheduler.py", line 10, in <module>
  File "/home/kivy/test/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/psutil/__init__.py", line 95, in <module>
  File "/home/kivy/test/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/psutil/_pslinux.py", line 26, in <module>
ImportError: dlopen failed: can't find ARM symbol

dlopen failed: can't find ARM symbol
souru7 commented 4 years ago

we are also facing this problem ImportError: dlopen failed: "/data/data/org.test.fpindia/files/app/_python_bundle/site-packages/cv2/cv2.so" has bad ELF magic please help Thanks...