GRRedWings / python3-android

Python 3 cross-compilation tools for Android.
BSD Zero Clause License
68 stars 17 forks source link

Load CHECK 'did_read_' failed on SDK: 29 #20

Closed JunaidBabu closed 2 years ago

JunaidBabu commented 2 years ago

I'm getting the following error on Android SDK:29 Any help is appreciated..

/data/local/tmp/build/usr/bin # ./python3                                                                                                                                                              
bionic/linker/linker_phdr.cpp:168: Load CHECK 'did_read_' failed
Aborted 
GRRedWings commented 2 years ago

Being the end of the year I don't have a lot of time to look at this right now. Is there a reason you need to target this specific SDK? I don't believe that the SDK version you target here needs to match your Android application.

eakteam commented 2 years ago

+1, same issue for me with default build

GRRedWings commented 2 years ago

I just ran a build and didn't have the abort. What steps and command are you using to build it?

eakteam commented 2 years ago

I'm using sudo docker run --rm -it -v $(pwd):/python3-android -v ${NDK_PATH}:/android-ndk:ro --env ARCH=arm64 --env ANDROID_API=23 python:3.10.0-slim /python3-android/docker-build.sh --enable-shared --without-ensurepip --disable-ipv6

After build is successful putting everything to /data/local/tmp and execute via adb shell : ./python3 .

And it fails with :

bionic/linker/linker_phdr.cpp:168: Load CHECK 'did_read_' failed
Aborted
GRRedWings commented 2 years ago

Once the build is complete you have the *.so file that you use to run python on Android. There is a sample app that should hopefully give you enough details to use it.

I'm not sure what you are trying to do with python in adb shell. But the way I have use it is through JNI inside of a running android application.

eakteam commented 2 years ago

i see the file at the bin folder and trying to execute via adb shell ?!

GRRedWings commented 2 years ago

I'd say check out the sample application. What is the goal of using Python on Android? I have a Java thread that calls in and runs a blocking Python script. So as long as the Python script is executing the java thread is blocked.

eakteam commented 2 years ago

I understand that but sometimes needs to execute Python as following via adb shell:

./data/local/tmp/usr/bin/python3 /data/local.tmp/somepythonfile.py and it fails.

Meanwhile python executable produced by termux works very fine with that way of execution

GRRedWings commented 2 years ago

I guess I don't understand the reason to run from adb, and why not use the native python for your OS.

Regardless, I don't believe this project will be able to run python from adb

eakteam commented 2 years ago

The reason from adb is because sometimes python should be executed from java proccess like :

val p = Runtime.getRuntime().exec(context!!.applicationInfo.nativeLibraryDir + "/libpython3.so /data/local/tmp/somepythonfile.py")

And after that, get InputStream/ErrorStream/OutputStream from that process and manipulate data or display right to the user without using more complex JNI methods.

Anyway, i think it should be simple workaround for that but i can't find the cause of bionic/linker/linker_phdr.cpp:168: Load CHECK 'did_read_' failed. As i said python libraries produced by https://github.com/termux/termux-packages/tree/master/packages/python works fine with that.

If you have some time to check it would be great. Best Regards...

GRRedWings commented 2 years ago

Have you tried a simple python script? It's possible not all libraries exist in mine that you need

eakteam commented 2 years ago

Yes, i have tried. The problem is not with python libs, the problems stands at python executable itself. You can try on your own.

Just extract files to tmp folder and try to execute python via adb, is the same as java process. If this issue fixed, this project is awesome and really easy to use for every circuimstances.

GRRedWings commented 2 years ago

Being honest, I maintain this for my own purposes, and don't have a lot of extra bandwidth for things outside that. Most likely I won't have much time to look into it.

eakteam commented 2 years ago

i understand... if you have any time for that, would be awesome.