How to use tweepy module with sl4a and py4a? - android

I am trying to build a twitter client written in python using tweepy and make it run on sl4a (using py4a) on Android. But i seem to fail to import tweepy module in my main script. The script does not run. Please tell me the correct way to use tweepy in sl4a because copy-pasting the tweepy directory in sl4a's scripts directory does not work.

Download the tweepy .egg for Python 2.6 here : https://pypi.python.org/pypi/tweepy/1.7.1 Make sure it is in the Downloads folder in your SD card. Launch the Python for Android app and select the "import module" option. Select the tweepy .egg file you just downloaded. It should work fine.

The Python for Android app allows you to import module zips, and there are instructions around the web and on the SL4A FAQ about where to copy modules to on the SD card to try and install them as well as installing Python Eggs [link]. You could also try running tweepy's setup.py (found in the download) on the phone.
However, it may also be possible that tweepy has other requirements not present on your phone, such as other modules that would normally be installed by easy_install or the like. While I don't think this is the case it would certainly make installing it very difficult.
At the end of the day, as per the FAQ, I think your best bet is to try copying the tweepy module directory into /sdcard/com.googlecode.pythonforandroid/extras/python.
Good luck!

Related

Porting C based linux application to the Android platform

I have C Linux based application and now I want to port it to Android.
I figured out, that I can extract the toolchain from Android NDK and build my application, but how to make the APK such that I can install it on the android devices without the need of root access.
In Linux, I used to install it using a bash script which used to put my application related files in different folders like /opt, /etc (files shared with other applications) and /var . How can we handle this in Android. Is there a folder similar to /etc in Android where I can put files that other applications can read.
Thanks
-M
First of all, you are lucky if your project compiles "as is" with NDK standalone toolchain. Often, bionic is not enough, and people need to tweak the build environment (from libpthread to full-blown buildroot alternate toolchain with static C runtime).
As for the shared files location, on Android it's named "external storage". Your app and other app may require special permissions to write and read to this location. Directory /opt does not exist here. You don't have write access to /etc, but files like /etc/hosts are available for read.
Regarding the APK. You are right, this is the ultimate way to distribute and install apps on Android. But you can, even without root, to locally install and run a command-line executable. Usually it's done with Developers Options turned on, and enabled USB debugging. Now you can open an adb shell, install and run your program. The trick is that external storage (see above) is marked as 'non-executable'. Therefore, you must find another place for your binary. Usually, /data/local/tmp will be a good choice.
Instead of adb, you can use a terminal emulator on the device.
If you choose to build an APK, you will probably prefer to convert your app to shared library that will perform actions for Java via JNI. But it is also possible to package your command-line binary as part of the APK and use Java Runtime.exec().

How can I install sl4a modules without internet access?

I have the necessary .zip files in the root directory of /sdcard. The language installers insist on using the internet. I'm thinking the .zip files are in the incorrect directory. What directory do I put the files; or if that is the wrong question, how can I get any of the sl4a languages installed?
sl4a supports .yak files . sl4a works on Android Emulator as well.To use, use adb install sl4a_rnn.apk
Forget that those files are even available for download. Use the built-in mandatory installer only after giving up at trying to integrate sl4a into my Eclipse workspace; because there is already a free distribution of Python in the Google Play store :)

How to integrate Python scripting in my Android App (like SL4A)

I need to add scripting layer to my android App. So I can remotely prepare a script that my app download form a web service and execute on the user device.
I found a interesting project called Scripting Layer for Android (SL4A) here:
http://code.google.com/p/android-scripting/
I'm not sure I can execute Python script without installing the PythonForAndroid_r4.apk first. I can't force my customer to install that application!
So my question is, can the SL4A layer be integrated in my app without the need to install other apk?
I need to execute actions like update data in the DB, create/read/delete a file on the sd card... Not so complex but I see SL4A can do a lot of things like these.
Other scripting libraries?
EDIT:
Found also MVEL: http://mvel.codehaus.org/ but I think it needs to be integrated to execute complex operations like accessing a DB...
I found a project that uses SL4A:
http://code.google.com/p/android-python27/
For whom that wants to try it, if error occurs using Eclipse, here is a link that could solve the compilation issue:
http://code.google.com/p/android-python27/issues/detail?id=1
I've just compiled this project:
http://code.google.com/p/android-python27/source/browse/#hg%2Fapk
To download sources, download HG Tortoise from:
http://tortoisehg.bitbucket.io/download/
Make a local copy of the repository with the command:
hg clone https://code.google.com/p/android-python27/
Then import the APK project in Eclipse and compile it.
Just run it on my low cost China tablet and it seems to works fine. Initially the program make an installation:
boolean installNeeded = isInstallNeeded();
if(installNeeded) {
setContentView(R.layout.install);
new InstallAsyncTask().execute();
}
That make some installations on the external storage (fortunately no root privileges are needed).

python scripting for android

I am trying to use eclipse and sl4a to create an android app for my tablet. I am following the procedure mentioned in this blog.
http://jokar-johnk.blogspot.com/2011/02/how-to-make-android-app-with-sl4a.html
I have my python scripts already compiled.
I need to make a '.apk' file using these python scripts, such that when I run the app in android, it should do what it is supposed to.
To create the '.apk' file, I am using eclipse with pydev plugin.
I created a clone of sl4a repository and imported to eclipse.
When I am creating a new project for android app development, I am not sure where to import my python scripts and embed them such that, at last I have an executable '.apk' file.
When I create a new project in eclipse, I see couple of folders like src, gen, res and several files under them. Where do I need to place my python scripts now? Do I need to create a separate folder under the project and directly import my python scripts or put them under src/gen/res?
As it says in that guide, you don't create a new project, you make a copy of the ScriptForAndroidTemplate template app, then:
"Right click on your_script_name then open with text editor. Delete
the default script, replace it with your own and save. Then
Clean/Build/Refresh your project and run it."
And it should work!
Re-read (and follow) the tutorial if you're still stuck. Good luck!

Download scripts for Android Scripting Environment

Downloaded ASE from google code, and was looking through tutorials, and available scripts.
I found a script I wanted to try, however copy pasting it is removing all whitespace (and this is a Python script...).
Is there a simple way to download a script from the internet into the Android Scripting Environment?
Copy the .py file to your SD card, under ase/scripts

Categories

Resources