m m -
d e v

newsite.. .

workinprogress!

broken,unfinishedbutlookifyoulike.. .

expectfrequentchanges!

Developing Software on Android Devices

13 minute read

Daily-driving Android as a dev environment.

Table of Contents

I get a lot of my development work done on Android devices. That usually means a large tablet, but it’s not impossible to get work done on smaller tablets or even phones (although the smaller you go, the harder it is to maintain ergonomics and practicality).

With Termux/PRoot Distro/Termux:X11 (explained below) I can run all of my most-used Linux apps just like I was sitting at a desktop, silently (ie no fans) and efficiently.

Performance on my S8 Ultra tablet is great — not as fast as the latest most powerful laptops but perfectly comfortable for my usage patterns.

A shortcut to a simple Termux script means I can tap an icon on my Android home screen and boot into the beautiful emptiness of an Ubuntu DWM session in about 5 seconds.

Hardware

My favourite and most commonly-used device is my Samsung Tab S8 Ultra:

  • 14.6" OLED display
  • 2960x1848 resolution
  • 16:10 aspect ratio
  • 8-core, 4nm processor
  • 8GB RAM

The OLED (my favourite display tech along side e-ink) screen is gorgeous. Black is really black and running everything in dark OLED (black) UI modes gets a little more out of the battery too.

This tablet is roughly on par with average modern laptops in terms of power, but has some advantages for me.

Ergonomics

This is the main reason I generally prefer a tablet over a laptop. With a laptop the screen is attached to the keyboard, meaning:

  • The display is always too low, so…
  • you hunch over…
  • which is bad for your back, and…
  • …affects your breathing, as…
    • your shoulders turn inwards and compress your chest cavity, so…
    • your breaths will be shorter and more shallow…
    • increasing a tendency towards feeling stressed or anxious

This may seem over-the-top, but we programmers spend a lot of time sitting at our machines. There’s no such thing as a good position to sit in all day, our bodies expect and require movement (I certainly need a lot more) — but some positions are better than others.

Another benefit of using portable/mobile devices for work is that you aren’t chained to a desk, so can move around to different seating positions throughout the day. As a self-contained unit a laptop is good for this too, but you’re still stuck with the screen and keyboard being attached to one another.

I attach the tablet to a monitor arm so I can position it at a good height (ie with the top of the screen being just below eye level). But if I want to spend some time in a different position, I have a simple tablet stand which folds flat (so takes up very little storage space) and can easily be placed on top of books or boxes to elevate my tablet.

Choice of Input Devices

In the past I’ve preferred ThinkPads for their great keyboards and little red TrackPoint pointing devices — I have an old but lovely X230 for when I do feel the need for a laptop.

Nowadays though, my favourite combo is a mechanical keyboard and trackball (the ‘fingers on top’ type of trackball suits me better than the ’thumb at the side’ type).

Of course these devices can be attached to laptops too, but then the laptop’s own keyboard and pointing device are just sitting there doing nothing. Laptops are good for travelling but for me sitting at home they’re a waste.

They used to make TVs with DVD players built-in, and common advice was that it wasn’t a wise buy, as if the DVD player stopped working you just had a wasted lump of electronics attached to your TV. I feel like this about laptops.

Ergodox Mechanical Keyboard

I like to use an Ergodox mechanical keyboard which I built myself from a kit and maintain (due to my terrible soldering joints regularly failing). This is a split keyboard, meaning it comes in 2 halves which can be positioned with a gap in the middle, allowing me to keep my arms a comfortable distance apart and avoid the hunching and bad posture. The keyboard is also programmable via the open source firmware QMK (great project btw).

As time goes by I am gradually removing keys from my layout and moving towards a layers/chording method of typing, meaning you have fewer keys and use more key combos. I’m ultimately aiming for a 40% layout (which vaguely means 40% of the number of keys on a normal keyboard). Fewer keys means fewer hand contortions and stretching fingers to fewer awkward positions, plus it makes the hardware smaller. Once I’m comfortable with that smaller number of keys I’ll build myself a Bluetooth LE Ferris keyboard or something similar.

My Ergodox is a wired USB version but I use it over Bluetooth via a BT500 Bluetooth adapter which converts any USB keyboard/mouse into Bluetooth. The BT500 is quite expensive for what it is (about $40) but I doubt they sell huge numbers of them so probably don’t have the economies of scale to make them cheaper. I had to order from the USA and wait a while to get it, but it’s a pretty cool and useful device.

Deft PRO Trackball

My trackball is a DEFT Pro. It works well for my purposes and feels comfortable enough. I try to use the keyboard instead of the pointer as much as possible but sometimes a mouse/trackball is needed, eg when editing images.

Power Management

Android/mobile devices treat this as an important feature whereas laptops don’t always take enough care over it, especially with Linux (where power management isn’t always the best, partly because device manufacturers don’t work as closely with Linux as they do Microsoft). This isn’t true for all laptops though, and things seem to be improving.

Most Android devices use ARM CPUs, which give strong performance for relatively low power usage.

I admit that Windows and MacOS tend to be better-tuned for power efficiency, but if I had to use those OSes I’d be wishing for my battery to die, just so I could stop. So, swings and roundabouts.

Adaptable and Easy to Store

I can be writing code one minute and very quickly change to watching a film or casual web browsing handheld mode the next.

As I’m often relying entirely on solar power for my electricity, being able to minimise the number of devices I need to keep charged up is a real benefit for me.

Also, living in a small space, tablets are flat and thin — so very efficient in terms of storage. Several can be stacked up on top of each other and take up no more space than a large book.

Software

Although this is all in relation to working on Android, the software I use is generally the same as if I was on a Linux desktop. That’s kind of the point, nowadays I can use almost the same environment on Android as I can on my desktop.

Termux

Termux is a brilliant free terminal app and Linux environment for Android. It has most of the Linux commands I need and I can install git, Vim, Tmux, mutt, ImageMagick and the majority of the terminal software I like to use. For certain jobs such as scripting, SSH sessions and writing, this is all I need.

Termux can run non-terminal, graphical apps too, but you won’t be able to see them. That’s what the next app is for.

Termux:X11

This amazingly useful app describes itself as being in early development, but I’ve been daily-driving it for months without significant issues.

Termux:X11 is an X Server for Termux. This allows you to install graphical Linux apps, as long as they are available for your system architecture (ie AArch64 — or ARM64 as it’s known — for most modern Android devices).

This means I can run, directly on my tablet:

  • Desktop Firefox (so, full developer tools)
  • Desktop Chromium (this was quite hard to get installed and isn’t the absolute latest version but is still very useful for development)
  • Krita/Inkscape/GIMP for image processing
  • Thunar file manager
  • Audacity (using PulseAudio over the network to pipe the audio up to Android by using the devices own IP address… I’m sure this creates some delay/latency but I’ve not noticed it in practice and for my typical usage of minor adjustments to audio files it works well)

PRoot Distro

This is a ‘container environment manager’ and allows you to easily install, uninstall, backup and restore Linux distributions, alongside/on-top-of Android, sharing the kernel.

It’s really simple to use, eg installing Debian Linux is a matter of opening Termux and entering:

proot-distro install debian

Then for a shell login:

proot-distro login debian

PRoot Distro provides a nice choice of distros including:

  • Alpine Linux (edge)
  • Arch Linux ARM
  • Artix Linux (AArch64 only)
  • Debian (stable)
  • Fedora 38 (AArch64 only)
  • Manjaro (AArch64 only)
  • OpenSUSE (Tumbleweed)
  • Pardus (yirmibir)
  • Ubuntu (23.10)
  • Void Linux

You can install as many distros as you want and swap between them easily. Each distro just sits in a directory on the Android device. Using the backup tools the entire system can be bundled up as a single archive file and moved over to another Android device.

Window Management

I believe that the best user interface (actually, interface of any kind) is one that I don’t even notice exists. It doesn’t shout at me, it doesn’t wow me with animations and eye-candy. It allows me to get to the tools I need to get the job done and stay immersed in the task. It is at peace with itself enough to take a back seat and not demand attention. It is, conceptually, transparent.

A lot of people like the gestural UI featured in ‘Minority Report’. I like the film, and the scene with Tom Cruise manipulating the UI is well produced and fun to watch. But as a UI it’s terrible! Hugely inefficient with all those big sweeping hand gestures, it’s not quick or practical. I don’t want to have to perform interpretive dance to use my computer (nor watch my computer doing little performances when I’m trying to get stuff done).

I found similar sentiment in this Daring Fireball article about the Apple Vision Pro:

“To me the Macintosh has always felt more like a place than a thing. Not a place I go physically, but a place my mind goes intellectually. When I’m working or playing and in the flow, it has always felt like MacOS is where I am. I’m in the Mac.

“Interruptions — say, the doorbell or my phone ringing — are momentarily disorienting when I’m in the flow on the Mac, because I’m pulled out of that world and into the physical one.”

I am nearly exactly like this too, except I don’t want to feel like I’m “in the Linux” (and definitely not “in the Mac” or “in Windows”!). I don’t want to be aware of that layer of abstraction at all. I don’t mind feeling that I’m “in Vim”, but really I want to be “in the code” that I’m editing. I specifically don’t want to feel the manicured claw of a corporate behemoth like Apple or Microsoft on my shoulder… but that’s just me.

I’d rather forget that my OS(/window manager) exists. It’s a facilitator, not an end in itself.

DWM: Tiling Window Manager

I used to prefer larger screens and multiple monitors. I knew about the concept of workspaces but they sounded annoying and fiddly. It took me a long time to give them a chance and it happened accidentally, as a side-effect of trying a tiling window manager.

Very briefly, a tiling window manager organises your windows into tiles, meaning instead of having oddly-sized overlapping windows floating around making a confusing mess of your screen and using space inefficiently, your screen splits into fractions, each being filled by an app. If you have too many apps on the screen they can go onto other screens, or ‘workspaces’. Personally I tend to run most apps fullscreen most of the time, switching between them with keyboard shortcuts.

I started with i3 Window Manager, which is a really nice piece of software. After a few years of using it though I realised I didn’t use most of its features, so landed on the very minimal Suckless Tools DWM.

With workspaces, each app can have its own screen and can be accessed instantly via a keyboard shortcut. With familiarity this becomes a chord in muscle memory, a hand-shape to mash at keyboard. I have habits for where I keep each app, so eg my terminal is in workspace 1 so [Alt]+[1] puts me in the terminal. [Alt]+[9] puts me in FireFox and so on.

I’ve [Alt]+[Tab]bed through apps in the past. Workspaces are similar except you know the keyboard chord will take you directly to the app you want, you don’t have to play ‘stop the magical app carousel at the right time’… which may be a drawback for some I guess, as carousels can be fun.

We can only focus on one thing at a time, that’s how attention works. I can see some uses for multiple screens eg if you have to monitor lots of things, like real-time charts or meters. In that case your peripheral vision is good at detecting change/motion so you can make use of all the space. But personally I’m completely over large/multiple displays. In my circumstances, they waste power, waste space, and are just not necessary.

Cons of Android for Development

The Low Memory Killer Daemon - Official Docs.

This feature of modern Android versions kills tasks (/apps) when it thinks they are causing memory-related performance problems. It can feel pretty heavy-handed, with apps abruptly closing at seemingly random intervals.

In practice this can irritate but I’ve never lost any work because of it. The most noticeable occurrence is when Termux:X11 closes — my Linux desktop suddenly shuts down! Sounds terrible But actually my Vim buffers are constantly auto-saved, my browser tabs are stored… I just have to restart the session, then Tmux, then maybe a couple of other items. I’m back up and running in 1-2 minutes, and this problem might occur once or twice per week at the most.

There are various ways to tweak the daemon though, search for terms like ‘disable android oom killer’, ’tweak low memory killer daemon android’ etc.

Missing Tools for ARM Architecture

As the types of CPU in Android devices (usually ARM) are not the same as those used in laptops/desktops (usually X86), the standard desktop versions of software can’t be installed and compatible versions must be available (unless you want to compile them yourself).

This isn’t as bad as it sounds as the package manager for whichever distro you use will automatically pull in the correct version for your CPU architecture. Some software might be missing though.

A couple of specific gaps in the system affect me:

  • Garmin Monkey C
    Garmin apps are written in their own language ‘Monkey C’, which has to use their own Java-based compiler and device simulator. As far as I can tell this isn’t happening on ARM. It was hard enough to get it working on Linux and Vim as they presume Windows/VSCode in their tutorials, so once I achieved that I didn’t take it any further.
  • Flutter cross-compilation
    The situation with Flutter is strange. Flutter is used to make multi-platform apps, so the same code can output apps for Linux, Android, Windows etc. I can build a Linux (ARM64) binary on my Android Ubuntu… and I can build an Android binary on my (normal, X86 desktop) Linux. But I can’t build an Android binary from Android. Apparently people were able to do this on older versions of Flutter, so it seems like Google (who control Flutter) intentionally stopped supporting it.

Fingers crossed!

Mine is a niche use-case and I understand that I can’t expect organisations to support such a tiny minority as ARM Linux. Apple’s M1/M2/M3 ARM chips are doing very well, which is great if you’re into that but I don’t enjoy their ecosystem.

So for now I need to hang on to my X86 desktop. But I hope ARM continues to gain recognition as more than a mobile phone CPU and can be used for more development tasks in future.