Update from Dustin DeWeese: “A working Emacs 25 package is available in Termux: https://termux.com
$ apt install emacs” — this is probably a better solution than the outdated distro below.
In February 2014, I posted instructions for installing Gnu Emacs in older versions of Android. These instructions no longer work in Android L (Lollipop), because of a new requirement that all executables be compiled with a position-independent (PIE) flag. I have managed to create a new binary from Michał Zieliński’s admittedly now out-of-date patched Emacs version, and have made it available on GitHub.
Since TerminalIDE also fails to run under Lollipop (lacking PIE), the instructions for installation are now somewhat different.
- Install some kind of a terminal emulator (JuiceSSH currently crashes, but others seem to work) in your Android. If you’re not rooted, then you must choose a terminal emulator that has its own home directory under
/data/, where you can make a file executable and run it (you cannot normally make a file executable under
- Create a new directory
/sdcard/emacs/to hold your non-executable files, such as eLISP files (you may choose a different location, but you’ll need to set some extra environment variables so that Emacs can find your files; that’s outside the scope of this posting).
- ₣rom my GitHub repo, download emacs.bin, copy it somewhere not on your
/sdcard/(your terminal emulator’s “home” directory if not rooted, or somewhere like
/data/local/bin/if rooted) and make it executable:
chmod 755 emacs.bin
- From my GitHub repo, download etc.tlzma, terminfo.tlzma, and lisp.tlzma, and unpack them all into your
/sdcard/emacs/directory — you may need BusyBox installed to get the unlzma and tar utilities required for unpacking, e.g.
unlzma -c lisp.tlzma | tar xvf -
- Somewhere on your executable path (perhaps /system/xbin/), create a new shell script called “emacs” containing a command like this:
#!/system/bin/sh HOME=/sdcard TERMINFO=/sdcard/emacs/terminfo /data/local/bin/emacs.bin "$*"
If your chosen terminal emulator already has TERMINFO installed, then don’t set it in the script. You may choose any home directory you want, but it must be writeable (Emacs will want to create a
$HOME/.emacs.d/directory to save settings).
- Make the new script executable (and make sure it’s on your execution $PATH):
chmod 755 emacs
- If your terminal type is unrecognised, you might need to add additional terminal types to emacs/terminfo; conversely, if your terminal emulator is already using a TERMINFO database somewhere, then don’t set the TERMINFO environment variable in your shell script.
- Crashes in a local shell under JuiceSSH — don’t know why yet (use a different terminal emulator). Update: only when the font is too large — seems related to screen width.
- Dates on
*.elcfiles are earlier than dates on
*.elfiles after running Michał’s build scripts; you should probably fix that with something like this:
find /sdcard/emacs/lisp -name '*.elc' -print0 | xargs -0 touch
- Starts with the message “WARNING: linker: /data/local/bin/emacs.bin has text relocations. This is wasting memory and prevents security hardening. Please fix.” — this seems to be a common problem in Android L, and I have not yet found the right combination of GCC flags to fix it.
Any volunteers to package all this up neatly, perhaps with some terminal emulator, for distribution in the Google Play Store?