Comments (20)
SL4A libraries are packaged in the APK in libs folder (script.jar):
http://code.google.com/p/android-python27/source/browse/apk/#apk%2Flibs [ see:
http://code.google.com/p/android-python27/wiki/TutorialHowToUpdateWithLatestSL4A
]
On Python side you have android.py in res/raw/python_extras_27.zip which
bridges your calls to SL4A, e.g.:
import android
droid = android.Android()
droid.makeToast("Hello from PC")
Original comment by [email protected]
on 6 Feb 2014 at 8:19
from android-python27.
I tryed to import android using adb shell on desktop:
adb shell
su
chmod 755 /data/data/org.modrana.PySideExample/files/python/bin/python
LD_LIBRARY_PATH=/data/data/org.modrana.PySideExample/files/python/lib
/data/data/org.modrana.PySideExample/files/python/bin/python
It can import android but It give error when I tryed your example:
<
Python 2.7.2 (default, Jul 10 2012, 02:50:07)
[GCC 4.4.3] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySide
>>> import android
>>> droid=android.Android()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/data/org.modrana.PySideExample/files/python/lib/python2.7/android.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "/home/tsheasha/GUC/Bachelors/android-python27/python-build/build/lib/python2.7/socket.py", line 553, in create_connection
socket.gaierror: [Errno 8] hostname nor servname provided, or not known.
I also tryed this with android device terminal, but got same error. My
application is based on modrana.org/trac/wiki/PySideForAndroid ,and android.py
is located res/raw/python_27.zip. It is located
/data/data/org.modrana.PySideExample/files/python/lib/python2.7/android.py on
device.
Android/libs have script.jar, locale_platform.jar, libGoogleAnalytics.jar,
guava-r06.jar in PySİde-android project.
I also tryed to import PySide in adb shell,
import PySide didnt give any error but
>>> import PySide.QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen failed: could not load library "libQtCore.so" needed by
"QtGui.so"; caused by library "libQtCore.so" not found
PySide library works good with device. Maybe I have mistake using adb shell. So
maybe SL4A can work too. I didnt test it yet. If I test it, I will report you.
Thank you.
Original comment by [email protected]
on 7 Feb 2014 at 7:23
from android-python27.
I did nou use this tutorial for running
Python(https://code.google.com/p/android-python27/wiki/TutorialHowToRunPythonfro
mShell), I used thp.io/2011/pyside-android/ for running it.
Regards
Original comment by [email protected]
on 7 Feb 2014 at 7:36
from android-python27.
>socket.gaierror: [Errno 8] hostname nor servname provided, or not known.
>My application is based on modrana.org/trac/wiki/PySideForAndroid
I don't know the modrana app but the error you hit means that the SL4A server
is not running (the socket cannot connect to the rpc server).
With android-python27 installed, from the command line you run the server with:
{{{
export AP_HOST=localhost
export AP_PORT=45777
am start -a com.android.python27.LAUNCH_RPC_SERVER -n
com.android.python27/.RpcServerLauncher --ei
com.android.python27.RPC_SERVER_PORT 45777
}}}
Then droid=android.Android() will work.
When you are in the context of the APK, the server is launched for you with
(see in
http://code.google.com/p/android-python27/source/browse/apk/src/com/android/pyth
on27/ScriptService.java):
mProxy = new AndroidProxy(this, null, true);
mProxy.startLocal();
So you would need to replicate one of this in your context.
SL4A scheme is simple, there is a RPC server running, the scripting languages
send request to this server via sockets (android.py), the server execute native
Java code and send back the results.
Original comment by [email protected]
on 7 Feb 2014 at 8:07
from android-python27.
I installed android-python27.apk on Android 4.04, ran this, It worked on
device. But I couldn't run the app both adb shell and android terminal.
I tryed them:
export AP_HOST=localhost
export AP_PORT=45777
am start -a com.android.python27.LAUNCH_RPC_SERVER -n
com.android.python27/.RpcServerLauncher --ei
com.android.python27.RPC_SERVER_PORT 45777
I got this error:
Starting: Intent { act=com.android.python27.LAUNCH_RPC_SERVER
cmp=com.android.python27/.RpcServerLauncher (has extras) }
Error type 3
Error: Activity class
{com.android.python27/com.android.python27.RpcServerLauncher} does not exist.
I also applied
https://code.google.com/p/android-python27/wiki/TutorialHowToRunPythonfromShell
in adb shell:
export PYTHONHOME=/data/data/com.android.python27/files/python
export
PYTHONPATH=/sdcard/com.android.python27/extras/python:/data/data/com.android.pyt
hon27/files/python/lib/python2.7/lib-dynload:/data/data/com.android.python27/fil
es/python/lib/python2.7
export PATH=$PYTHONHOME/bin:$PATH
export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/com.android.python27/files/python/li
b:/data/data/com.android.python27/files/python/lib/python2.7/lib-dynload
python can work in adb shell, But hello.py didn't work.
cd /data/data/com.android.python27/files/
python hello.py
gave error:
Traceback (most recent call last):
File "hello.py", line 3, in <module>
droid = android.Android()
File "/sdcard/com.android.python27/extras/python/android.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "/home/tony/Desktop/xcross/android-python27/python-build/build/lib/python2.7/socket.py", line 571, in create_connection
socket.error: [Errno 111] Connection refused
Then for testing SL4A API:
export AP_HOST=localhost
export AP_PORT=45777
am start -a com.android.python27.LAUNCH_RPC_SERVER -n
com.android.python27/.RpcServerLauncher --ei
com.android.python27.RPC_SERVER_PORT 45777
gave error:
Starting: Intent { act=com.android.python27.LAUNCH_RPC_SERVER
cmp=com.android.python27/.RpcServerLauncher (has extras) }
Error type 3
Error: Activity class
{com.android.python27/com.android.python27.RpcServerLauncher} does not exist.
I think problem is connecting SL4A server and RPC server. I installed SL4A and
Python for android (2.6) and I connected SL4A server so SL4A scripts can work
with adb shell. (with SL4A wiki)
Original comment by [email protected]
on 15 Feb 2014 at 10:36
from android-python27.
I don't see why this error popup:
"Error: Activity class
{com.android.python27/com.android.python27.RpcServerLauncher} does not exist."
Can you send me the apk you are using ?
Original comment by [email protected]
on 15 Feb 2014 at 11:35
from android-python27.
Sorry, not android-python27.apk, I installed PythonAPK.apk:
https://code.google.com/p/android-python27/downloads/detail?name=PythonAPK.apk&c
an=2&q=
Original comment by [email protected]
on 15 Feb 2014 at 1:34
from android-python27.
First I try to learn connection between SL4A server and PythonAPK example. Then
I will apply to connect this with PySide example.
Pyside apk : http://speedy.sh/MtHmA/PySideExample-1.0.apk
Python source : http://speedy.sh/RWSKU/android-pyside-example-project-master.zip
Regards
Original comment by [email protected]
on 15 Feb 2014 at 2:12
from android-python27.
Also My goal is to use SL4A API in PySide GUI with Python27. Such as GPS
sensor, bluetooth, etc
Original comment by [email protected]
on 15 Feb 2014 at 2:31
from android-python27.
>Sorry, not android-python27.apk, I installed PythonAPK.apk:
Understood then, this is an old APK, I added RpcServerLauncher later on so you
just need to build the android-python27.apk from HEAD and use it, then all will
work as expected.
Original comment by [email protected]
on 15 Feb 2014 at 2:32
from android-python27.
As I told at 2. comment, I tested SL4A hello world example in PySide Example
from source, but It didnt worked.
>I added RpcServerLauncher later on so you just need to build the
android-python27.apk from HEAD and use it, then all will work as expected.
Sorry HEAD means from source? I just know to test PySide projects sources from
Necessitas or PyDroid.
Original comment by [email protected]
on 15 Feb 2014 at 2:43
from android-python27.
Try attached new PythonAPK. Don't forget to uninstall previous one before
installing this one.
Original comment by [email protected]
on 15 Feb 2014 at 2:46
Attachments:
from android-python27.
Thank you, I will try it.
Original comment by [email protected]
on 15 Feb 2014 at 2:48
from android-python27.
Hi, I tested new apk, but gave error again.
First:
adb shell
root@android:/ # su
export PYTHONHOME=/data/data/com.android.python27/files/python
export
PYTHONPATH=/sdcard/com.android.python27/extras/python:/data/data/com.android.pyt
hon27/files/python/lib/python2.7/lib-dynload:/data/data/com.android.python27/fil
es/python/lib/python2.7
export PATH=$PYTHONHOME/bin:$PATH
export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/com.android.python27/files/python/li
b:/data/data/com.android.python27/files/python/lib/python2.7/lib-dynload
root@android:/ # cd /data/data/com.android.python27/files
root@android:/data/data/com.android.python27/files # python hello.py
Traceback (most recent call last):
File "hello.py", line 3, in <module>
droid = android.Android()
File "/sdcard/com.android.python27/extras/python/android.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "/sdcard/com.android.python27/extras/python/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] hostname nor servname provided, or not known
Second:
root@android:/ # export AP_HOST=localhost
root@android:/ # export AP_PORT=45777
on27/.RpcServerLauncher --ei com.android.python27.RPC_SERVER_PORT 45777 <
Starting: Intent { act=com.android.python27.LAUNCH_RPC_SERVER
cmp=com.android.python27/.RpcServerLauncher (has extras) }
root@android:/ # python
Python 2.7.2 (default, Nov 16 2012, 19:13:11)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> droid=android.Android()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/sdcard/com.android.python27/extras/python/android.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "/sdcard/com.android.python27/extras/python/socket.py", line 571, in create_connection
raise err
socket.error: [Errno 111] Connection refused
This time RPC server started however droid=android.Android() didn't work. I
don't know what I missed. Should I try this with an android emulator too? (My
OS is Ubuntu 13.10.)
Regards
Original comment by [email protected]
on 15 Feb 2014 at 11:07
from android-python27.
Could be the port was in use by the first failed attempt (failed because
RpcServerLauncher has not been started before droid=android.Android()), try to
reboot and check with netstat -a (also ps | grep python). Then try again, start
RpcServerLauncher, start python, droid=android.Android().
If fail again try in an emulator.
Original comment by [email protected]
on 15 Feb 2014 at 11:46
from android-python27.
Yes droid=android.Android() worked after I did your instruction. But
droid.makeToast("Hello from PC") gave error.
>>> import android
>>> droid=android.Android()
>>> droid.makeToast("Hello from PC")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/sdcard/com.android.python27/extras/python/android.py", line 58, in rpc_call
return self._rpc(name, *args)
File "/sdcard/com.android.python27/extras/python/android.py", line 49, in _rpc
result = json.loads(response)
File "/sdcard/com.android.python27/extras/python/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/sdcard/com.android.python27/extras/python/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/sdcard/com.android.python27/extras/python/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Original comment by [email protected]
on 16 Feb 2014 at 12:30
from android-python27.
Hi, fortunatelly It worked today. I applied this tutorial again :
https://code.google.com/p/android-python27/wiki/TutorialHowToRunPythonfromShell
I tryed this tutorial many times and this always didn't work and gave error.
But I don't know why It worked today. Now I will try to export paths to the
PySİde example in adb shell in accordance with this tutorial for connecting
SL4A.
Thanks
Original comment by [email protected]
on 16 Feb 2014 at 12:37
from android-python27.
I edited my_python_project.zip's main.py in PyDroid example
(https://code.google.com/p/android-python27/source/browse/#hg%2Fpython-build-wit
h-qt%2FPyDroid%2Fandroid%2Fres%2Fraw)
import android
droid = android.Android()
droid.makeToast("Hello from PC")
After that, app did not work. But when this code is deleted, app can work. Is
it possible to use SL4A with PyQt GUI in this example?
Regards
Original comment by [email protected]
on 18 Feb 2014 at 12:55
from android-python27.
PyDroid example's error is pyqt-error.txt:
Traceback (most recent call last):
File "/data/data/org.kde.necessitas.example.PyDroid/files/main.py", line 35, in <module>
main()
File "/data/data/org.kde.necessitas.example.PyDroid/files/main.py", line 20, in main
droid=android.Android()
File "/data/data/org.kde.necessitas.example.PyDroid/files/python/lib/python2.7/android.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "/home/tsheasha/GUC/Bachelors/android-python27/python-build/build/lib/python2.7/socket.py", line 553, in create_connection
gaierror: [Errno 8] hostname nor servname provided, or not known.
Original comment by [email protected]
on 18 Feb 2014 at 5:07
from android-python27.
PyDroid / SL4A issue moved to
http://code.google.com/p/android-python27/issues/detail?id=35
Original comment by [email protected]
on 25 Feb 2014 at 10:49
from android-python27.
Related Issues (20)
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Patna +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Vadodara +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Ghaziabad +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Faridabad +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Rajkot +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in navi mumbai +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Allahabad +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Dehradun +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Karnal +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantra for love success in Mohali +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantras for love in Bangalore +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantras for love in Pune +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantras for love in Hyderabad +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantras for love in Mumbai +91-8875513486
- +91-8875513486 %%!!రామ్ దేవ్ జీ%%! vashikaran mantras for love in New Delhi +91-8875513486
- How can I pass String value from EditText In Android Activity to Python Script and also make the activity able to retrieve the String result from a function in the python script ?
- Interaction with python file
- Install on external storage
- Can't install android-python27 to Samsung Galaxy 4
- how to create android app in eclipse using python code on windows 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-python27.