Can't seem to get Bluetooth scripts (using either SL4A Bluetooth Serial, or
PyBluez) to run when packaged as an APK, and I'm getting precious little
feedback from Logcat what's going wrong.
Using the same Eclipse project I can successfully deploy and launch APKs
containing hello.py scripts which are similar in their functionality except
they do not use bluetooth.
These BlueZ- and SL4A- bluetooth serial scripts work consistently when launched
interactively or within SL4A, but they die when run from the APK environment.
Having failed to get SL4A bluetoothConnect(...) to work, (errors described at
https://groups.google.com/forum/?fromgroups=#!topic/android-scripting/aCWUGHgLqL
k) I tried instead to use PyBluez functionality which is preferred.
Once again this works when run from the Python console on the phone, or through
SL4A, but does not launch when deployed as an APK.
To try and incorporate PyBluez support in the APK I took the contents of the
egg file from
https://code.google.com/p/python-for-android/downloads/detail?name=PyBluez-0.19-
py2.6-linux-armv.egg and extracted the files and folders into the path
/python/lib/python2.7/dynload/ in the python_27.zip within the project. I don't
know if this is the right place, but it seemed the most consistent. I tried
extracting to some other paths in the supporting zips too, but no luck so far.
The moment I substitute a bluetooth-using scripts in the place of hello.py,
LogCat simply reports that the python process has died, with the following
lines after the installation and extraction of the APK...
03-15 18:25:35.432: V/sl4a.SimpleServer:225(21946): Bound to localhost/127.0.0.1
03-15 18:25:35.472: I/BlueshrimpAPK(21946): Executing
/data/data/com.android.python27/files/python/bin/python with arguments
[/data/data/com.android.python27/files/hello.py, --foreground] and with
environment {ANDROID_SOCKET_zygote=10,
AP_HANDSHAKE=e77ff97e-91e1-4a75-a0e8-1fba1f6fc6eb, ANDROID_BOOTLOGO=1,
EXTERNAL_STORAGE=/mnt/sdcard, ANDROID_CACHE=/cache, ANDROID_ASSETS=/system/app,
PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin,
ASEC_MOUNTPOINT=/mnt/asec,
PYTHONPATH=/mnt/sdcard/com.android.python27/extras/python:/data/data/com.android
.python27/files/python/lib/python2.7/lib-dynload:/data/data/com.android.python27
/files/python/lib/python2.7, AP_HOST=127.0.0.1, LOOP_MOUNTPOINT=/mnt/obb,
TEMP=/mnt/sdcard/com.android.python27/extras/tmp,
BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/sys
tem/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.
policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar,
SD_EXT_DIRECTORY=/sd-ext, AP_PORT=46999, DOWNLOAD_CACHE=/cache/download,
ANDROID_DATA=/data, PYTHONHOME=/data/data/com.android.python27/files/python,
LD_LIBRARY_PATH=/data/data/com.android.python27/files/python/lib:/data/data/com.
android.python27/files/python/lib/python2.7/lib-dynload, ANDROID_ROOT=/system,
ANDROID_PROPERTY_WORKSPACE=9,32768}
03-15 18:25:35.472: D/dalvikvm(21946): Trying to load lib
/data/data/com.android.python27/lib/libcom_googlecode_android_scripting_Exec.so
0x405183d0
03-15 18:25:35.482: D/dalvikvm(21946): Added shared lib
/data/data/com.android.python27/lib/libcom_googlecode_android_scripting_Exec.so
0x405183d0
03-15 18:25:35.482: D/dalvikvm(21946): No JNI_OnLoad found in
/data/data/com.android.python27/lib/libcom_googlecode_android_scripting_Exec.so
0x405183d0, skipping init
03-15 18:25:40.122: D/BlueshrimpAPK(21946): Process 22083 exited with result
code 1.
03-15 18:25:40.223: I/Process(21946): Sending signal. PID: 21946 SIG: 9
03-15 18:25:40.252: I/ActivityManager(231): Process com.android.python27 (pid
21946) has died.