There had been many scenarios where I wished if mobile phone could be used as a development machine. Scenarios such as quick SSHing to servers or pushing a hotfix to Github while on the roads, testing out a snippet which just popped in mind while jogging, etc.
I tried to make Nexus 5 as a pocket development machine. I was able to set it up, but with some limitations. Here is what all I did:
Part A: Full system access with Lineage OS & root user
- Connect phone to laptop via USB. Verify by listing connected devices:
$ adb devices
- Reboot phone to bootloader screen:
$ adb reboot bootloader
- Flash TWRP image for Nexus 5:
$ fastboot devices $ fastboot oem unlock $ fastboot flash recovery twrp-3.2.3-0-hammerhead.img
- Now, from bootloader screen, reboot in recovery mode. This would load TWRP app.
Sideload Lineage OS & gapps files:
- Lineage OS 15.1 can be downloaded from XDA - unofficial build. (Current official build is 14.1)
- For Nexus 5 GApps, I downloaded ARM 8.1 pico package.
(Optionally you can wipe existing data from TWRP’s Wipe option.)
$ adb sideload lineage-15.1-20180923-UNOFFICIAL-hammerhead.zip $ adb sideload open_gapps-arm-8.1-pico-20190312.zip
Then reboot the system. You’ll have to go through OS initial setup process.
SU Addon for root access
arm 15.1and copy to phone.
$ adb push addonsu-15.1-arm-signed.zip /sdcard
Reboot in recovery mode to go to TWRP app, Install > select
After that reboot the system. Lineage OS with root access is ready now!
Part B: Development Setup
There are many terminal apps available in Google Playstore. I chose Termux, which has powerful terminal emulation with essential Linux package collection.
The default location of Termux’s bash is
Few basic commands:
$ pkg search <term> $ pkg show <packages> $ pkg list-all $ pkg list-installed $ pkg install <packages> $ pkg reinstall <packages> $ pkg uninstall <packages> $ apt list --upgradable $ pkg upgrade $ pkg help
1. Text Editor
pkg search editor can help you to get a glimpse of available editors in termux package repo.
emacs are few choices.
$ pkg install -y vim
$ pkg install -y git
Add public key to your Github account.
$ pkg install -y hub $ git config --global user.email "<email>" $ git config --global user.name "<username>"
$ pkg install -y zsh
$ git clone git://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh --depth 1 $ cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
$HOME/.termuxfolder & add the following files for theme customization:
Restart Termux to make zsh as default shell.
$ chsh -s zsh $ exit
$ pkg install -y openssh $ ssh-keygen -t rsa -b 4096 -C "<email>"
Connect to remote servers from phone:
$ ssh [email protected]
SSH into phone:
Start SSH server daemon in phone:
Password SSHing is difficult, add your public key to
Then, from any other device:
$ ssh -p 8022 <IP_address_of_phone>
Stop SSH daemon:
$ pkill sshd
5. Programming languages
Language packages such as
perl, etc. are available.
Now we can clone any repo, edit in vim & commit to Github, SSH to a remote server and do a quick snippet compilation. Pretty much what all I needed 🎉
- Since Termux has access to only
/data/data/com.termux, we can’t create our
projects/folder outside of that location.
- Since project files are in app specific location, we can’t use any code editor apps such as DroidEdit which is running outside of that user scope.
suroot shell can’t run termux packages directly.
A workaround for using termux packages in root shell is to export
LD_LIBRARY_PATHpointing to termux’s
/usr/lib/and execute package binaries by specifying path:
$ export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib/ $ /data/data/com.termux/files/usr/bin/python --version $ /data/data/com.termux/files/usr/bin/vim test.txt
If there is a way to solve these limitations, please let me know in comments.