Reprinted from: http://code.qtuba.com/article-50680.html
I recently looked at head first Python, which has chapters on Python's development in Android, but I need to get an android emulator, so I started tossing on Ubuntu.
One, because the Android SDK is running on top of Java, you have to configure the JDK
On Oracle's website i downloaded the JDK7 32-bit installation package for Linux jdk-7u55-linux-i586.tar.gz
I then applied the mkdir JVM command under/usr to create a directory of the JVM. Move the jdk-7u55-linux-i586.tar.gz to the/USR/JVM directory and apply the TAR-ZXVF jdk-7u55-linux-i586.tar.gz decompression.
In the Linux terminal Input command sudo vim/etc/profile add the following lines at the end of the file:
Export Java_home=/usr/jvm/jdk1.7.0_55 #jdk所在的目录
Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH
Export classpath= $CLASSPATH:.: $JAVA _home/lib: $JAVA _home/jre/lib
Then, in the terminal input command Source/etc/profile, you can detect your Java environment now:
Second, to http://developer.android.com/sdk/index.html
A, download the Android SDK specifically for Linux, I'm under: android-sdk_r22.6.2-linux.tgz. Unzip the compressed file and go to its tools directory,
When you enter the Android SDK on the terminal, the Android SDK Manager opens:
Download some of the tools you need for Android development here.
B. Enter the Android AVD on your Linux terminal
You can create an Android virtual machine:
Click the New button to create an Android virtual machine, create details, I will not repeat.
Currently I have created a virtual machine named Python_test:
Look through the Android List AVD command to view your new Android virtual machine python_test:
C. Open the/etc/profile file to configure the environment variables
$sudo Vim/etc/profile
Add these lines at the bottom of the file,
The directory where the export Android_home=/home/jack/python/android/android-sdk-linux #android SDK
Export path= $android _home/tools: $android _home/platform-tools: $PATH
D, it is better to restart the computer for the configured environment variables to take effect:
In our lovely terminal,
$emulator @python_test, see, that's how it works.
Third, this is a more exciting step, began to configure our Python on the Android operating environment, the application is sl4a. Enter https://code.google.com/p/android-scripting/
Click QR Code to download, my is sl4a_r6.apk, then go to Downloads page:
Apply the ADB tool to install the downloaded two files into your Android virtual appliance:
Install those two apk files
$ADB Install sl4a_r6.apk
$ADB Install pythonforandroid_r4.apk
Once installed, go to your Android emulator and click on the app icon after the sl4a_r6.apk is installed:
Like you wrote a hello_world.apk.
In the terminal $adb push hello_world.apk/sdcard/sl4a/scripts, import into the emulator
This file will then be detected in sl4a, click Hello_world.apk, and then click the second button like set to run the Python file:
Basically all this, if you are interested, you can toss a bit.
Use Python and sl4a Android apps to build your own Android development environment under Ubuntu