wei-spring / android-python27

Automatically exported from code.google.com/p/android-python27
0 stars 0 forks source link

Microsoft Acess DB(.mdb) in Python APK #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Including MS Access database file in my_python_project.zip
2. Create an apk file using eclipse 
3. Run on emulator/samsung galaxy tab

What is the expected output? What do you see instead?
The app need to run on the Galaxy tablet and create a text file with desired 
results(summary). The app crashes instead.

What version of the product are you using? On what operating system?
Samsung Galaxy tab. Android( Honeycomb Sandwich)

Please provide any additional information below.

I am accessing microsoft access DB in my python scripts. I included my database 
file along with my_python_project.zip file. The python apk file installs but 
crashes later on. Please suggest suitable ways of including MS Access database 
in python apk file. 

Original issue reported on code.google.com by vb...@mst.edu on 16 Oct 2012 at 7:49

GoogleCodeExporter commented 9 years ago
Could you provide the logcat of the crash and scripts ?

Original comment by anthony....@gmail.com on 16 Oct 2012 at 7:54

GoogleCodeExporter commented 9 years ago
Thanks for your response. I am attaching the logcat of the crash. I have 
attached an additional word document with just the errors for your convenience. 
I can send the scripts after getting it approved from my supervisor.

Original comment by vb...@mst.edu on 16 Oct 2012 at 4:24

Attachments:

GoogleCodeExporter commented 9 years ago
The app cannot find the script to launch: 

"Caused by: java.lang.RuntimeException: No such script to launch."

This means your "my_python_project.zip" is not correct, either you don't use 
main script name "hello.py", or if you use another name e.g. "foo.py" you did 
not change the name in 
https://code.google.com/p/android-python27/source/browse/apk/src/com/android/pyt
hon27/config/GlobalConstants.java

public static final String PYTHON_MAIN_SCRIPT_NAME = "hello.py"; 

Original comment by anthony....@gmail.com on 16 Oct 2012 at 4:46

GoogleCodeExporter commented 9 years ago
I have a file in my_python_project.zip that I renamed as hello.py. However, I 
am not sure if hello.py requires any 'import android' commands in it. All my 
scripts inside my_python_project.zip are all python scripts which do not use 
any 'import android'. These scripts use libraries such as 'pyodbc', 'python 
win32', and 'wx python'. I copied all the required libraries in to python 
27_extras.zip. 

Original comment by vb...@mst.edu on 16 Oct 2012 at 6:34

GoogleCodeExporter commented 9 years ago
No need to 'import android'. Note 'python win32' 'wx python' are not supported.

Original comment by anthony....@gmail.com on 16 Oct 2012 at 6:39

GoogleCodeExporter commented 9 years ago
When I embed these libraries 'python win32' and 'wx python' in the zip files 
along with the interpreter, is it not that the application tries to link the 
'Lib' folder under python 27_extras.zip. And in the errors, it does not say 
about missing libraries or 'unable to import python win32' or similar. I tried 
to do the traditional way in eclipse, without zipping the files and without 
embedding python interpreter in apk. Even in here, it did not give an error on 
missing libraries.  

Original comment by vb...@mst.edu on 16 Oct 2012 at 6:53

GoogleCodeExporter commented 9 years ago
I am trying to understand the errors I got. Can you suggest me a way that I can 
get to know what these errors are? Fatal exception async task #2, #3, and other 
errors such as java.lang.runtimeexception etc. I guess that the starting five 
errors on gps config and system/bin/tc are not related to the python scripts 
and more related to emulator. Please correct me if I am wrong. Are all the 
errors inter-related such that if I fix some of those, the others get fixed, or 
they all are separate?

Original comment by vb...@mst.edu on 17 Oct 2012 at 3:32

GoogleCodeExporter commented 9 years ago
There is only one error: "No such script to launch" i.e. malformed project .zip.

In addition: 'python win32' and 'wx python' won't work, extension contains C 
code that needs to be cross-compiled (+ win32 API won't exists).

Original comment by anthony....@gmail.com on 17 Oct 2012 at 4:53

GoogleCodeExporter commented 9 years ago
Thanks for the information. I will work on it and update you. 

Original comment by vb...@mst.edu on 17 Oct 2012 at 5:16

GoogleCodeExporter commented 9 years ago
I did not understand the part "extension contains C code that needs to be 
cross-compiled" in your previous mail. Could you please explain more about it? 
Thanks for your help! 

Original comment by vb...@mst.edu on 23 Oct 2012 at 12:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
If you take a look e.g. at PyCrypto sources: 
http://pypi.python.org/pypi/pycrypto/2.6

You will see that C code is used to create this extension, so the way to build 
it is platform dependent. For Android you need to compile this C code for ARM, 
you're using the android NDK for that.

Original comment by anthony....@gmail.com on 23 Oct 2012 at 7:13

GoogleCodeExporter commented 9 years ago
Thanks for providing me the information. I will look into it.

Original comment by vb...@mst.edu on 23 Oct 2012 at 2:42

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The main problem is that AFAIK distutils/setuptools does not handle 
cross-compilation so your modules would need setup.py to be patched to set up 
the right compiler. Then each C extension brings its own series of *little* 
troubles to fix on the way. 

Original comment by anthony....@gmail.com on 23 Oct 2012 at 2:56

GoogleCodeExporter commented 9 years ago
If I add the below patch in my setup.py, do you think it will work? 
export ANDROID_NDK=[PATH WHERE THE ANDROID NDK IS]
export 
PATH="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
/:$ANDROID_NDK:$ANDROID_NDK/tools:/usr/local/bin:/usr/bin:/bin"
export ARCH="armeabi"
export CFLAGS="-DANDROID -mandroid -fomit-frame-pointer --sysroot 
$ANDROID_NDK/platforms/android-5/arch-arm"
export CXXFLAGS = "$CFLAGS"
export CC="arm-linux-androideabi-gcc $CFLAGS"
export CXX="arm-linux-androideabi-g++ $CXXFLAGS"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip --strip-unneeded"
export MAKE="make -j4 HOSTPYTHON=[PATH TO HOST PYTHON] HOSTPGEN=[PATH TO HOST 
PGEN] CROSS_COMPILE=arm-eabi- CROSS_COMPILE_TARGET=yes"

I am also using .mdb files i:e; MS Access database in my project. Does Android 
support Access database? Also, I am using openDSS for GUI, does Android support 
this too? Please let me know. I can only move further if Android supports all 
these functionalities . Thanks a lot for your help!

Original comment by vb...@mst.edu on 23 Oct 2012 at 4:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Here are changes I did to add PyCrypto (check diff): 
https://code.google.com/p/android-python27/source/detail?r=550dbd9a832effd466a6f
0ebed9e9c3a1f7e7399

You can try to replicate smth like that for your extension, but each extension 
come with its specific stuff.

At first sight it seems the requierements of your project won't fit great with 
Android.

Original comment by anthony....@gmail.com on 24 Oct 2012 at 7:06