{"id":2039,"date":"2011-01-27T09:58:59","date_gmt":"2011-01-27T01:58:59","guid":{"rendered":"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/?p=2039"},"modified":"2011-01-27T10:39:06","modified_gmt":"2011-01-27T02:39:06","slug":"running-python-on-android","status":"publish","type":"post","link":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/?p=2039","title":{"rendered":"Running Python on Android"},"content":{"rendered":"<p>See this <a href=\"http:\/\/www.akeric.com\/blog\/?p=879\">http:\/\/www.akeric.com\/blog\/?p=879<\/a> for reference but the info is somewhat outdated.<\/p>\n<p>#1. Install Android SDK. There&#8217;s some path problem for the 64 bits java with the SDK. I install 32 bits java instead. You can also install Eclipse and ADT if you have time.<\/p>\n<p>#2. Create the Android Virtual Device using the installed SDK Manager<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/sdk1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2040\" title=\"sdk1\" src=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/sdk1-300x137.png\" alt=\"\" width=\"300\" height=\"137\" srcset=\"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/sdk1-300x137.png 300w, https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/sdk1.png 997w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><a href=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture.png\"><\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2042\" title=\"Capture\" src=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture1-300x267.png\" alt=\"\" width=\"300\" height=\"267\" srcset=\"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture1-300x267.png 300w, https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture1.png 480w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>#3. Install the Android Scripting Environment (ASE), now called SL4A (Scripting Layer for Android)<\/p>\n<ul style=\"padding-left: 30px;\">\n<li>Get sl4a_r*.apk and python_for_andorid_r*.apk from <img decoding=\"async\" src=\"file:\/\/\/C:\/Users\/sfluk\/AppData\/Local\/Temp\/moz-screenshot-1.png\" alt=\"\" \/><a href=\"http:\/\/code.google.com\/p\/android-scripting\/downloads\/list\">http:\/\/code.google.com\/p\/android-scripting\/downloads\/list<\/a><\/li>\n<li>Use adb to install the two apk<\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\">C:\\Program Files (x86)\\Android\\android-sdk-windows\\platform-tools&gt;adb install sl4a_r*.apk<\/p>\n<p>#4. Configure the SL4A<\/p>\n<p style=\"padding-left: 30px;\">Launch the SL4A and add the installed Python to it<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2046\" title=\"Capture\" src=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture2-181x300.png\" alt=\"\" width=\"181\" height=\"300\" srcset=\"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture2-181x300.png 181w, https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture2.png 498w\" sizes=\"auto, (max-width: 181px) 100vw, 181px\" \/><\/a><\/p>\n<p style=\"padding-left: 30px;\">You will see some sample scripts installed as below<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2048\" title=\"Capture\" src=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture3-180x300.png\" alt=\"\" width=\"180\" height=\"300\" srcset=\"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture3-180x300.png 180w, https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture3.png 491w\" sizes=\"auto, (max-width: 180px) 100vw, 180px\" \/><\/a><\/p>\n<p>#5. Upload a prepared script to the SL4A<\/p>\n<ul style=\"padding-left: 30px;\">\n<li>Run &#8220;adb shell&#8221; to get an interactive shell to find the location of the python scripts placed. The path found is \/mnt\/sdcard\/sl4a\/scripts<\/li>\n<li>Use &#8220;adb push&#8221; to put your script to the path above. eg: adb push peter.py \/mnt\/sdcard\/sl4a\/scripts<\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2050\" title=\"Capture\" src=\"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture5-180x300.png\" alt=\"\" width=\"180\" height=\"300\" srcset=\"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture5-180x300.png 180w, https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/wp-content\/uploads\/2011\/01\/Capture5.png 491w\" sizes=\"auto, (max-width: 180px) 100vw, 180px\" \/><\/a><\/p>\n<p>#6. Conclusion : I have to say, the interactive performance of the emulator is really slow. This is making the experience of interactive debugging and editing of the script rather disgusting. It is OK to test and run a simple script with a few lines. For complicated scripts, may be it is better to debug and run on the Android Pad with a physical keyboard attached??<\/p>\n<p>PS: Use Ctrl-F11 to rotate the screen of the emulator<\/p>\n<p style=\"padding-left: 30px;\">\n<p style=\"padding-left: 60px;\">\n","protected":false},"excerpt":{"rendered":"<p>See this http:\/\/www.akeric.com\/blog\/?p=879 for reference but the info is somewhat outdated.<\/p>\n<p>#1. Install Android SDK. There&#8217;s some path problem for the 64 bits java with the SDK. I install 32 bits java instead. You can also install Eclipse and ADT if you have time.<\/p>\n<p>#2. Create the Android Virtual Device using the installed SDK Manager<\/p>\n<p> [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[3],"tags":[83],"class_list":["post-2039","post","type-post","status-publish","format-standard","hentry","category-computer","tag-android","odd"],"_links":{"self":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2039"}],"version-history":[{"count":9,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2039\/revisions"}],"predecessor-version":[{"id":2045,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2039\/revisions\/2045"}],"wp:attachment":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}