Android/Developing on Android

The software for the vast majority of Android applications is written and edited on a laptop PC or desktop PC.

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.

However, there are several ways of writing and editing software directly on the Android device. Some of them 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).

Termux
Termux is an open-source Android terminal emulator and Linux environment app that works directly with no rooting or setup required.

Bash script Hello World
Here is a quick "Hello World":

Install Termux by the method you prefer.

Tap the "Termux" icon.

At the command prompt, type

(I'm assuming you've done a little programming before, so you'll know when to press the  button at the end of the line).

Enter a quick bash script:

Then press the Ctrl + X, "y" and Enter to save the program and quit back to the command prompt.

Execute the script:

You should see the output saying "Hello, world.".

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,

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:

(using backquotes, not apostrophes).

Anyway - start telnetd with:

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]

[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

['' 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 Termux to ssh to a remote server
You can ssh from your Android device in Termux into your favorite servers. Type your username, at-sign, and domain name like so:

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.