sofdigital / DroidPython

Python app development with SL4A in Android Studio
MIT License
55 stars 17 forks source link

ABI #1

Closed viperfx closed 8 years ago

viperfx commented 8 years ago

Does this require an ARM based ABI image emulator to successfully run? I tried to launch it with an x86 emulator and it was throwing an error while launching the app.

michaelrinderle commented 8 years ago

I would imagine that would be the case, since I compiled the python executable for ARM. I always push to my physical devices so I haven't run across this problem yet. Emulators are just to slow and janky for me...

Can you provide logcat details to confirm? It's most likely that but Just curious...

viperfx commented 8 years ago

huh. I actually switched back to an X86 emulator and now the app actually launches and crashes. Before it was having trouble installing to the emulator. I got the error INSTALL_FAILED_NO_MATCHING_ABIS

So the stack trace I get in my x86_64 emulator is....

04-12 08:54:47.384 7365-7389/com.android.python32 I/Process: Sending signal. PID: 7365 SIG: 9
04-12 08:54:48.156 7693-7693/com.android.python32 W/System: ClassLoader referenced unknown path: /data/app/com.android.python32-2/lib/x86_64
04-12 08:54:48.462 7693-7693/com.android.python32 W/System: ClassLoader referenced unknown path: /data/app/com.android.python32-2/lib/x86_64
04-12 08:54:48.650 7693-7725/com.android.python32 V/sl4a.SimpleServer:225: Bound to /127.0.0.1
04-12 08:54:48.681 7693-7725/com.android.python32 I/Python32APK: Executing /data/user/0/com.android.python32/files/python3/bin/python3 with arguments [/data/user/0/com.android.python32/files/hello.py, --foreground] and with environment {ANDROID_ROOT=/system, AP_PORT=38114, AP_HANDSHAKE=f2d4b047-c164-41e6-a558-28f97c8bc4b3, ANDROID_BOOTLOGO=1, AP_HOST=127.0.0.1, LD_LIBRARY_PATH=/data/user/0/com.android.python32/files/python3/lib:/data/user/0/com.android.python32/files/python3/lib/python3.2/lib-dynload, EXTERNAL_STORAGE=/sdcard, SYSTEMSERVERCLASSPATH=/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar, PYTHONHOME=/data/user/0/com.android.python32/files/python3, ANDROID_SOCKET_zygote=10, PYTHONPATH=/storage/emulated/0/com.android.python32/extras/python3:/data/user/0/com.android.python32/files/python3/lib/python3.2/lib-dynload:/data/user/0/com.android.python32/files/python3/lib/python3.2, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ANDROID_DATA=/data, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, TEMP=/storage/emulated/0/com.android.python32/extras/tmp, BOOTCLASSPATH=/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.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/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar, ANDROID_PROPERTY_WORKSPACE=9,0, ANDROID_STORAGE=/storage}

                                                                 --------- beginning of crash
04-12 08:54:48.681 7693-7725/com.android.python32 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                    Process: com.android.python32, PID: 7693
                                                                    java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                        at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                        at java.lang.Thread.run(Thread.java:818)
                                                                     Caused by: java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-script_fd45592cc9db96ae391425952a16d2a854811f16-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-locale_platform_3b58a722730550fb919de062b6ef468d947a9a97-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-libGoogleAnalytics_efcb261814875b57d4f97d9a40afec5b3328a0fb-classes.dex", dex file "/data/data/com.android.python32/files/instant-run/dex/slice-guava-18.0_e12d857ef6a31dff4418b3f14dd7989adf12d59a-classes.dex"],nativeLibraryDirectories=[/data/app/com.android.python32-2/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libcom_googlecode_android_scripting_Exec.so"
                                                                        at java.lang.Runtime.loadLibrary(Runtime.java:367)
                                                                        at java.lang.System.loadLibrary(System.java:1076)
                                                                        at com.googlecode.android_scripting.Exec.<clinit>(Exec.java:68)
                                                                        at com.android.python32.process.Process.start(Process.java:137)
                                                                        at com.android.python32.process.InterpreterProcess.start(InterpreterProcess.java:138)
                                                                        at com.android.python32.process.MyScriptProcess.launchScript(MyScriptProcess.java:61)
                                                                        at com.android.python32.BackgroundScriptService.startMyMain(BackgroundScriptService.java:182)
                                                                        at com.android.python32.BackgroundScriptService.access$000(BackgroundScriptService.java:45)
                                                                        at com.android.python32.BackgroundScriptService$startMyAsyncTask.doInBackground(BackgroundScriptService.java:138)
                                                                        at com.android.python32.BackgroundScriptService$startMyAsyncTask.doInBackground(BackgroundScriptService.java:131)
                                                                        at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                        at java.lang.Thread.run(Thread.java:818) 
04-12 08:54:50.498 7693-7725/com.android.python32 I/Process: Sending signal. PID: 7693 SIG: 9
viperfx commented 8 years ago

I actually have no particular use case for using python3. So I will try with python2 and get back to you.

On Tue, Apr 12, 2016 at 12:06 PM, michael notifications@github.com wrote:

actually i can't speak for the python3 package. since i forked the old android-python project, I have only been overhauling the py2 apk so far but kept it in to eventually update too. i'll have to look into this. i know the major reason the project died was that the py executables weren't working anymore on android 5.0+ without PIE. thanks for posting the logcat..

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ainsophical/droid-python/issues/1#issuecomment-208983771

Tharshan

viperfx commented 8 years ago

Hmm I am running into the same issue as before:


04-12 12:39:05.139 2535-2644/com.android.python27 I/PythonAPK: Executing /data/user/0/com.android.python27/files/python/bin/python with arguments [/data/user/0/com.android.python27/files/hello.py, --foreground] and with environment {ANDROID_ROOT=/system, AP_PORT=53193, AP_HANDSHAKE=36da0502-857d-4a45-9237-0ed4aa0a46a9, ANDROID_BOOTLOGO=1, AP_HOST=127.0.0.1, LD_LIBRARY_PATH=/data/user/0/com.android.python27/files/python/lib:/data/user/0/com.android.python27/files/python/lib/python2.7/lib-dynload, EXTERNAL_STORAGE=/sdcard, SYSTEMSERVERCLASSPATH=/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar, PYTHONHOME=/data/user/0/com.android.python27/files/python, ANDROID_SOCKET_zygote=11, PYTHONPATH=/data/user/0/com.android.python27/files/packages/python:/data/user/0/com.android.python27/files/python/lib/python2.7/lib-dynload:/data/user/0/com.android.python27/files/python/lib/python2.7, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ANDROID_DATA=/data, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, TEMP=/data/user/0/com.android.python27/files/packages/tmp, BOOTCLASSPATH=/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.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/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar, ANDROID_PROPERTY_WORKSPACE=9,0, ANDROID_STORAGE=/storage}
04-12 12:39:05.145 2535-2644/com.android.python27 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
                                                                    Process: com.android.python27, PID: 2535
                                                                    java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                        at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                        at java.lang.Thread.run(Thread.java:818)
                                                                     Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.android.python27-1/base.apk"],nativeLibraryDirectories=[/data/app/com.android.python27-1/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libcom_googlecode_android_scripting_Exec.so"
                                                                        at java.lang.Runtime.loadLibrary(Runtime.java:367)
                                                                        at java.lang.System.loadLibrary(System.java:1076)
                                                                        at com.googlecode.android_scripting.Exec.<clinit>(Exec.java:68)
                                                                        at com.android.python27.process.Process.start(Process.java:137)
                                                                        at com.android.python27.process.InterpreterProcess.start(InterpreterProcess.java:137)
                                                                        at com.android.python27.process.MyScriptProcess.launchScript(MyScriptProcess.java:61)
                                                                        at com.android.python27.BackgroundScriptService.startMyMain(BackgroundScriptService.java:182)
                                                                        at com.android.python27.BackgroundScriptService.access$000(BackgroundScriptService.java:45)
                                                                        at com.android.python27.BackgroundScriptService$startMyAsyncTask.doInBackground(BackgroundScriptService.java:138)
                                                                        at com.android.python27.BackgroundScriptService$startMyAsyncTask.doInBackground(BackgroundScriptService.java:131)
                                                                        at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                        at java.lang.Thread.run(Thread.java:818) 
04-12 12:39:05.323 2535-2549/com.android.python27 E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f3dbc659f30
04-12 12:39:05.637 2535-2549/com.android.python27 W/EGL_emulation: eglSurfaceAttrib not implemented
04-12 12:39:05.637 2535-2549/com.android.python27 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7f3db5f8f880, error=EGL_SUCCESS
04-12 12:39:05.809 2535-2549/com.android.python27 V/RenderScript: 0x7f3dbabbe000 Launching thread(s), CPUs 2
04-12 12:39:07.858 2535-2644/com.android.python27 I/Process: Sending signal. PID: 2535 SIG: 9
04-12 12:39:08.993 2699-2699/com.android.python27 W/System: ClassLoader referenced unknown path: /data/app/com.android.python27-1/lib/x86_64
04-12 12:39:09.136 2699-2719/com.android.python27 V/sl4a.SimpleServer:225: Bound to /127.0.0.1
04-12 12:39:09.144 2699-2719/com.android.python27 I/PythonAPK: Executing /data/user/0/com.android.python27/files/python/bin/python with arguments [/data/user/0/com.android.python27/files/hello.py, --foreground] and with environment {ANDROID_ROOT=/system, AP_PORT=58040, AP_HANDSHAKE=37e3dbe8-fd58-449c-8014-dbac087fc363, ANDROID_BOOTLOGO=1, AP_HOST=127.0.0.1, LD_LIBRARY_PATH=/data/user/0/com.android.python27/files/python/lib:/data/user/0/com.android.python27/files/python/lib/python2.7/lib-dynload, EXTERNAL_STORAGE=/sdcard, SYSTEMSERVERCLASSPATH=/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar, PYTHONHOME=/data/user/0/com.android.python27/files/python, ANDROID_SOCKET_zygote=11, PYTHONPATH=/data/user/0/com.android.python27/files/packages/python:/data/user/0/com.android.python27/files/python/lib/python2.7/lib-dynload:/data/user/0/com.android.python27/files/python/lib/python2.7, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ANDROID_DATA=/data, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, TEMP=/data/user/0/com.android.python27/files/packages/tmp, BOOTCLASSPATH=/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.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/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar, ANDROID_PROPERTY_WORKSPACE=9,0, ANDROID_STORAGE=/storage}
04-12 12:39:09.151 2699-2719/com.android.python27 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                    Process: com.android.python27, PID: 2699
                                                                    java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                        at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                        at java.lang.Thread.run(Thread.java:818)
                                                                     Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.android.python27-1/base.apk"],nativeLibraryDirectories=[/data/app/com.android.python27-1/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libcom_googlecode_android_scripting_Exec.so"
                                                                        at java.lang.Runtime.loadLibrary(Runtime.java:367)
                                                                        at java.lang.System.loadLibrary(System.java:1076)
                                                                        at com.googlecode.android_scripting.Exec.<clinit>(Exec.java:68)
                                                                        at com.android.python27.process.Process.start(Process.java:137)
                                                                        at com.android.python27.process.InterpreterProcess.start(InterpreterProcess.java:137)
                                                                        at com.android.python27.process.MyScriptProcess.launchScript(MyScriptProcess.java:61)
                                                                        at com.android.python27.BackgroundScriptService.startMyMain(BackgroundScriptService.java:182)
                                                                        at com.android.python27.BackgroundScriptService.access$000(BackgroundScriptService.java:45)
                                                                        at com.android.python27.BackgroundScriptService$startMyAsyncTask.doInBackground(BackgroundScriptService.java:138)
                                                                        at com.android.python27.BackgroundScriptService$startMyAsyncTask.doInBackground(BackgroundScriptService.java:131)
                                                                        at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                        at java.lang.Thread.run(Thread.java:818) 
viperfx commented 8 years ago

Looks like I need an ARM image either way right? Because its looking for the so file in the x86_64 dir?

michaelrinderle commented 8 years ago

yes, looks like a mismatch with cpu arch / no matter what the py ex is compiled in arm.

./gradlew installDebug --stacktrace --offline && adb shell monkey -p com.android.python27 -c android.intent.category.LAUNCHER 1

when you install, use gradle to deploy. run that in your apk dir. i usually only use adb to get in and debug python errors....

viperfx commented 8 years ago

Are those instructions for an emulator or a device? Is there a way to compile for an x86 right now?

michaelrinderle commented 8 years ago

i use that to deploy to my physical devices but it should recognize any device connected including emulators (however I cannot confirm). Its the python executable youre having a problem with not the java, so it's a matter of ripping out the python executables (including std libraries with c extensions) and putting in those executables compiled in said architecture.

i don't have a reason to switch up but if there is more support for it, I guess I would add when I have time to do it. For now, I would just assume it will only work on ARM for the time being.

michaelrinderle commented 8 years ago

i recall recompiling the executables with the android ndk being a big pain to get the PIE flags working for android 5.0+ so i wouldn't be looking forward to it again.