smarthero50 / android-python27

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

How to use SL4A on PyDroid #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. İnstalled PyDroid on Android device (4.0)
2. Opened adb shell, and tryed to active RPC Launcher (whith this: 
https://code.google.com/p/android-python27/wiki/TutorialHowToRunPythonfromShell 
)

What is the expected output? What do you see instead?

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.

What version of the product are you using? On what operating system?
Lubuntu 13.10

Please provide any additional information below.

How to active RPC server launcher and use SL4A on PyDroid?

Original issue reported on code.google.com by edips...@gmail.com on 25 Feb 2014 at 8:04

GoogleCodeExporter commented 9 years ago
The PyDroid APK do not embed SL4A, some changes would be needed to add this 
feature.

Original comment by anthony....@gmail.com on 25 Feb 2014 at 10:47

GoogleCodeExporter commented 9 years ago
If PyDroid APK could embed SL4A, it would be very useful like Kivy UI. Now Kivy 
uses Plyer instead of SL4A, so it is possible to create effective application 
with it. (https://github.com/kivy/plyer). Qt-QML is more stable and rich GUI 
than Kivy. So I though PyQt-PySide with SL4A would be better than Kivy. I hope 
PyDroid will embed SL4A or Plyer.

Thank you.

Original comment by edips...@gmail.com on 26 Feb 2014 at 9:17

GoogleCodeExporter commented 9 years ago
I think it would not be complicated to add. Note that pyQT here is only QT4, 
with the new QT5 (Android support) this might be soon deprecated.

Original comment by anthony....@gmail.com on 26 Feb 2014 at 9:36

GoogleCodeExporter commented 9 years ago
Fixed in 
https://code.google.com/p/android-python27/source/detail?r=be1f3ab3183765efbc640
544676d2b4f6c297b93

Original comment by anthony....@gmail.com on 27 Feb 2014 at 8:29

GoogleCodeExporter commented 9 years ago
Thank you very much! I tryed to build the app according to Readme, changed 
/home/tsheasha/.. locations. Failed to build app because there are still many 
locations need be changed. Then I applied fixes on PySide example according to 
PySide Android tutorial, which uses Python27 for android project.( 
http://qt-project.org/wiki/PySide_for_Android_guide ), It built apk but app did 
not opened. I did not put "android/libs/armeabi/libPyDroid.so" file and did not 
edit main.h and PyDroid.pro paths (PySideExample.pro) for pyside-example 
project. I will try to edit python paths according to your project. If still 
does not work I will try to active GPS sensor using PyDroid project with Plyer 
(by Kivy). (https://github.com/raaron/pydroid and 
https://github.com/kivy/plyer) pyjnius and PySide can work with PyDroid. I 
tryed examples of this project and they work. Plyer is alternative of SL4A. I 
tested GPS example of this project using Kivy, and this actived GPS on device. 
I will try them. If one of them works, I will report here.

Regards

Original comment by edips...@gmail.com on 27 Feb 2014 at 11:04

GoogleCodeExporter commented 9 years ago
You just need to import this project into eclipse: 
http://code.google.com/p/android-python27/source/browse/#hg%2Fpython-build-with-
qt%2FPyDroid%2Fandroid

And change your sdk path in local.properties (and have installed Android SDK 
api 17 or change project.properties to reflect your installed sdk api level)

Then the APK should build fine.

Original comment by anthony....@gmail.com on 27 Feb 2014 at 11:22

GoogleCodeExporter commented 9 years ago
APK worked fine with SL4A. Thank you! :)

Original comment by edips...@gmail.com on 28 Feb 2014 at 1:13

GoogleCodeExporter commented 9 years ago
When app is opened first time, It can works with SL4A. But when app is opened 
second time app can work without SL4A. Its error: 

Traceback (most recent call last):
  File "/data/data/org.kde.necessitas.example.PyDroid/files/main.py", line 31, in <module>
    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 edips...@gmail.com on 1 Mar 2014 at 9:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
PythonAPK can work on device without problem. After running RPC launcher, then 
entering python paths on adb shell, it  runs SL4A script only once from 
terminal for PythonAPK. So it requires to run RPC launcher again for activating 
SL4A script. I could not run RPC launcher with PyDroid example, however reason 
of error may be activiting SL4A server while apk is running.

Original comment by edips...@gmail.com on 1 Mar 2014 at 10:22

GoogleCodeExporter commented 9 years ago
I guess rather easy to fix.

Original comment by anthony....@gmail.com on 2 Mar 2014 at 7:47

GoogleCodeExporter commented 9 years ago
Sorry. Those fixes kill your time, but I always try to fix them before I ask 
you. If PyQt-PySide can be used with SL4A, this can be alternative of Kivy. 
Just problem, size of APK is too much :)

Original comment by edips...@gmail.com on 2 Mar 2014 at 8:50

GoogleCodeExporter commented 9 years ago
I applied your fix to PySide example project too. It worked with SL4A script at 
first installation, then it did not open. PySide example has Meego Harmattan 
QML components which can be easily created GUI, and can be used instead of Qt 
Quick 2.0.

Original comment by edips...@gmail.com on 3 Mar 2014 at 12:52

GoogleCodeExporter commented 9 years ago
Also SL4A dialog scripts don't work with PyQt-PySide.  (tested get input and 
Bluetooth-chat example scripts)

Original comment by edips...@gmail.com on 4 Mar 2014 at 1:36