24/7 Android development with AIDE, Git and Raspberry Pi

Most typical Android developers use a single machine to code their application from start to finish. If you happen to be a casual Android developer, that is develop outside of working hours, then access to your code is limited to when you next use your desktop or laptop. However, this need not be the norm. With some clever software and cheap hardware, working anywhere virtually anywhere becomes possible.The home office with your desktop, slobbing in front of the tv with your laptop, and on perhaps your commute on my your android phone. Here’s the software and hardware required to achieve this.

    • Desktop pc with eclipse
    • Laptop with eclipse
    • Mobile phone with AIDE and thumb keyboard.
    • Raspberry Pi with Git source control

The first two probably do not need explanation, if you are a seasoned Android developer, so we won’t explain further. However, developing on your mobile will be new to some, but before we move onto that let’s look into what glues them altogether.

Git

Git is a source control system that has a very small footprint, is fast, easy to setup and manage. It was developed for distributed development by Linus Torvald who wanted an efficient source control system to develop the Linux operating system. You can read why he developed Git on this wiki page. At the very least, you should be using a source version control anyway. The main benefits being backup, comparing file changes, and the ability to rollback individual files to previous versions of the source code.

AIDE

AIDE was developed by AppFour (https://play.google.com/store/apps/details?id=com.aide.ui), and is a fully integrated development environment on Android devices . If you’re used to working in Eclipse then you will probably understand some of the concepts and principles of this tool. Namely

Code completion Easy navigation Refactoring Code Formatting

device-2014-02-01-134741
Git access from AIDE

What makes AIDE so powerful in this setup is its integration with Git. You can easily pull the latest code from your repository, make your changes and push your changes back. But there is still one issue to overcome with development on mobile phones.

Thumb keyboard

The problem with using AIDE on a mobile device such as a phone is the keyboard. Most virtual keyboard layouts are designed for users sending text messages or emails. So, common symbols that are required for a programming language like Java often require a number of key presses to achieve.

aide_thumb
Thumb Keyboard with AIDE

In addition, cursors on the keyboard is also a big plus as it allows you to navigate around the code. An almost perfect keyboard for using Git is the thumb keyboard. See our review of it here. You will need to use AIDE in landscape mode to take full advantage o of the keyboard. In this mode, the cursor keys appear, as well as the number keys in the centre. In addition, a lot of the symbols that you use in your source code appear as secondary characters. This let’s you just long press a key to enter an obscure symbol such as a curly bracket or semicolon. On large phones with screens of 4.7 inches and beyond this setup is very useful for short periods of coding such as the daily commute. Even if you do not want to write the code, you can analyse what you need to do and put TODO tags with descriptions. Later on, when you get home, just push your changes to your Git server, and implement the changes on your desktop. Eclipse has a view that lists all your TODO tags, so it’s easy to find what needs to be done.

Raspberry Pi

You can run Git on your desktop or a spare desktop if you want. However, you will need to keep it running 24 hours, which can be expensive. Git will be idle the majority of the time, and will only take up resources when you are transferring code. So a cheap low powered device, with enough processing power to run Git is all that is needed. The Raspberry Pi is a perfect solution. It’s a low cost computer that runs a flavour of Linux, and also has access to a wide range of open source software, including Git. In addition to the Raspberry Pi, you will also need An SD card – you probably have an old one lying around. 4gb will be sufficient. HDMI connector – only really needed for initial setup. If your monitor does not include HDMI input, a VGA adapter is required. Keyboard and monitor – any standard keyboard would do. Again only needed for initial setup. Optional wifi use – if you do not have an ethernet cable within reach. The following links detail how to setup Raspberry Pi with a Linux operating system. The version is irrelevant, as long as Git is supported. Note: You will need some basic Unix/Linux skills here raspbery pi setup Next Git needs to be installed. This is usually as straight forward as typing in the following command on the Pi.

sudo apt-get install git

More detailed instructions are here. http://quick2wire.com/articles/a-gentle-guide-to-git-and-github/

Setting up your first project.

Typically you would already have an android based project that you need transferring to Git. First log on to your Pi server and create a bare repository using the following commands.

mkdir your_project_name.git
cd your_project_name.git
git -bare init

Then on the machine where your code resides type the following. cd <project_name> Note that you will need gitignore file before checking in. Here is a sample for a typical android project set.

bin/
gen/
.directory
.settings/
*.apk
lint.xml
*.class
.classpath
.project
local.properties
project.properties
*~
*.swp
*.kate-swp
errors/
design/
testplan/
scalability/
play-assets/
docs/

copy this file to your project directory as .gitignore (note the fullstop/period before the name). This ensures that you do not copy class files and other temporary files over to your git repository. The following commands will do the intial checkin to the git repository on your Raspberry Pi. If you make a mistake you can always start again by deleting the .git folder. You check what has been transferred over to the Raspberry Pi with the gitk command. Typical Usage on pc Get the latest code Goto the project and type

git pull

To grab the latest code from the server. File change status After making show changes, you can see what files have changed with.

 git status

View flew change differences

git difftool

Let’s you look at the differences of your current changes against the previous version. Update main repository Makes your changes. Note unlike some other version control software, promoting your code to the main repository requires two commands. First you commit with

git commit -m “change details”

You do not need to be connected to the server for this command . Then you push your changes onto the server with

git push

Note that there is no need to checkout your files before making changes, which is great if you happen to refactoring your code slot. Git usage in Aide Adding a new project with Git You can copy a git project from your raspberry pi server to your phone ring Aide, using the clone for repository option. The URI that it prompts for will typically be something like

user@host:/home/pi/repo/project.git

After you have cloned your project into Aide, you are now able to continue coding your project on your phone. As it is with using git on your computer, you will need to commit your changes before pushing on the git server. Note that for committing you do need to be near your raspberry pi git server Also, before heading out, remember to pull the latest changes. Hopefully this article provided you with some useful tips for accomplishing your android development on a variety of devices and locations.