The software for the vast majority of Android applications is written and edited on a laptop PC or desktop PC.
However, there are several ways of writing and editing software directly on the Android device.[1][2]
Some people think trying to write software directly on an Android device or other tablet is so different than writing it on a PC that it requires a new programming language supported by a completely new IDE.[3]
Spartacus Rex has written a terminal IDE for Android[4][5] [6][7][8] that takes a very traditional approach. It supports software development using a traditional command prompt; traditional text editors such as "vi"; the standard programming language for Android (Java); and the standard compiler for that language (gcc). The only thing non-traditional is that it runs them all directly on the Android device itself. (Even that can be seen as a return to a much older tradition of developing and compiling software on the same machine that runs the software).
JavaScript Hello World
The Terminal IDE was originally intended to be used for Java development, but it can also be used for JavaScript. Here is a quick "Hello World":
Tap the "Terminal IDE" icon.
Tap the "Terminal IDE" button.
At the Spartacus Rex command prompt,[9] type
cd ~/sdcard ;
vim a.html
(I'm assuming you've done a little programming before, so you'll know when to press the Enter
button at the end of the line).
Type "i" to get into insert mode, then enter a quick JavaScript program:
<script>
document.write( "hello." );
alert("hi!");
</script>
Then press the ESC button and ":wq" to save the program and quit back to the command prompt.
Hit the Home button and fire up your favorite web browser, and use this URL:
file://sdcard/sdcard/a.html
You should see the "hi" alert pop up on top of a page saying "hello.".
Basic system setup
Follow all these tutorials through EXACTLY.
They will help you compile the sample applications in ~/system/src step by step.
The best way to follow these tutorials is by logging in over telnet/ssh and then you can read and follow on the device, whilst using the computer to perform the actions.
Let's Begin..
Installing the basic system.
Click 'Install System' on the main page, and then follow the instructions.
Make sure you have enabled the Terminal IDE Keyboard in Settings>Language and Keyboard on your device. Then choose the Terminal IDE keyboard - click 'Keyboard' on the main page.
Start Terminal IDE. Click the button..
You will now be presented with a nice not-short color prompt. You can change this by typing,
export PS1=#
But it does look really nice over telnet/ssh.. :-p
- Double-tap toggles the keyboard.
- Swipe left and right to view your 4 Terminals.
- Long pressing the screen brings up the Terminal Chooser menu.
- Press 'Menu' for Options
[This part is optional but highly recommended]
Run telnetd. No parameters are required. Defaults setup in ~/.bashrc. You can see what is actually being run by typing:
# cat `which telnetd`
(using backquotes, not apostrophes).
Anyway - start telnetd with:
# telnetd
You should now see telnetd startup info. Ending in ../system/bin/bash
You can shut telnetd down at any stage by typing [CTRL]-C on the Terminal IDE Keyboard
Now, go to your nice big computer and login via telnet. I have set the escape character to blank, as it is the same as the vim help link follow key.
[Either]
$ telnet -e [THE PHONES IP] 8080
[Or - better still with adb, which is part of the Android SDK] Plug your phone into computer via USB first. In you Android's developer options turn on Developer options and check USB debugging, then
$ adb -d forward tcp:8080 tcp:8080
$ telnet -e '' 127.0.0.1 8080
['' is 2 single quotes not a double quote]
Now you should be connected to the system via telnet
[And you can connect multiple times simultaneously]
OK - let's start programming.
Using terminal IDE to ssh to a remote server
You can ssh from your Android device in Terminal IDE into your favorite servers. Type your username, at-sign, and domain name like so:
ssh dc@dreamhost.com
The first time you connect from a particular Android device to a particular server, you will see something like:
Host 'dreamhost.com' is not in the trusted hosts file. (fingerprint md5 c4:ad:7f:ba:d8:23:d4:da:53:07:76:a2:7e:24:9d:67) Do you want to continue connecting? (y/n)
So type "y" and hit Enter
You must do this directly on the Android device's keyboard the first time you connect to a particular server. If you are telnetted to your phone from some other machine, you will get the error
ssh: connection to dc@dreamhost.com:22 exited: Didn't validate host key
until you go back to the Android device and type the command directly from the Android device's keyboard.
Synchronization
The Terminal IDE includes "rsync", which is very useful for copying files, making backups, and quickly checking if files in two places are actually the same or not. [10]
Further reading
- (Later: add a few words about using dropbearkey to generate a local private key that never leaves the smartphone, and the corresponding public key ... so we never need to type in a password to securely log in to a remote server.)[10][11]
- The Terminal-IDE Organization
- "cloning from GitHub on Android using Terminal IDE"
- "Getting git Working on Android Devices" (Using Terminal IDE)
- "SSH and GIT on Android with Terminal IDE"
- ↑ Brian Kracoff. "15 Apps for Programming on Android". 2012. Mentions "Terminal IDE" from Spartacus Rex, "AIDE", "C4droid", "Pocket Code for Android", "Algoid", etc.
- ↑ Eric Ravenscraft. "AIDE Is An IDE That Lets You Write And Compile Android Apps On Your Android Device".
- ↑ Marc Hesenius, Carlos Dario Orozco Medina, Dominikus Herzberg. "Touching Factor: Software Development on Tablets". 2012. doi: 10.1007/978-3-642-30564-1_10 .
- ↑ "Terminal IDE"
- ↑ Spartacus Rex. "Terminal IDE"
- ↑ "terminal-ide"
- ↑ "Terminal IDE help" documentation
- ↑ "Z-sharpened console terminal for Android"
- ↑
As you can check by typing
echo $SHELL
; the Spartacus Rex command prompt is a normal "bash" command line. See LPI Linux Certification/Work On The Command Line for a brief introduction. - 1 2 Jason York. "Using Public Keys With Dropbear SSH Client". quote: "Now that ssh works, I can easily perform an automated rsync".
- ↑