Update: these instructions no longer work for Android L (Lollipop). For a first pass at installing Gnu Emacs in Lollipop, see this update.
Since I mentioned in a review that I’m using Emacs on my Android Nexus 7 tablet, I’ve received several requests for information about how I set it up. There is a prepackaged Emacs app in the Google Play store, but it does not work as distributed, because it bundles a broken terminal application. The Emacs binary itself is fine, though, and with a bit of manual work, you can install it to run inside a different terminal application (I use Terminal IDE below).
Note: Emacs needs a full-featured PC-style keyboard. I usually run Emacs on my tablet with an external Bluetooth keyboard; if you want to use a soft keyboard, consider installing the Hacker’s Keyboard, which has all of the modifier keys Emacs expects.
Request: Would anyone be willing to rebundle Emacs in an easily-installable form for Terminal IDE, and make this blog posting obsolete?
Installing Emacs for Terminal IDE
Install the Terminal IDE app on your Android device.
In your Android browser, go to http://emacs.zielm.com/data/ and download the files
lisp.tlzma, then copy them to your Terminal IDE home directory.
Launch a shell in Terminal IDE and run the following commands:
$ unlzma emacs.lzma $ chmod 755 emacs
At this point, you should already be able to run emacs by typing
(though it will fail because it can’t find its etc directory). If you want, just put it somewhere on your executable path, like you would in any Linux installation.
Create a directory
/sdcard/emacs/(or make it somewhere different, if you’re willing to set environment variables to tell Emacs to look somewhere else).
Copy the downloaded files
Change to the
/sdcard/emacs/directory and run the following commands:
$ unlzma etc.tar.lzma $ tar xvf etc.tar $ unlzma lisp.tar.lzma $ tar xvf lisp.tar
Test that emacs starts up OK now (run from wherever you installed the binary):
If all is well, you can optionally delete the tar files to save space:
$ rm /sdcard/emacs/etc.tar /sdcard/emacs/lisp.tar
Enjoy Emacs in Android! You might consider doing an
C-u 0 M-x byte-recompile-directoryon
/sdcard/emacs/lisp/(and any other lisp directories) to make sure you’re up to date.
Wonderful. So now I will be interested in an Android tablet. Anyone know if a version of miktex exists (will exist) for android to complete what many of us need?
It should be possible to compile from source in Android via Terminal IDE (which includes gcc), but you’ll probably have to work around a lot of issues with where executables are stored, compile some libraries, etc. Cross-compiling from a Linux laptop will probably be easier (though I haven’t tried setting up a cross-compilation environment).
I followed the instruction, but at the end, it says “Permission denied”.
I even did chmod as a root. Still it says “can’t execute: Permission denied”
You can’t chmod it on the shared sdcard — it has to happen in a directory that terminator emulator owns.
Thanks for the message.
I have only etc.tlzma, and lisp.tlzma
How do I change these to etc.tar.lzma and lisp.tar.lzma?
Try using the Unix MV command.
I didn’t know you can just rename them. It works perfectly!
Thanks so much. My life will be different now….
Would you be willing to write a shell script which can be run from Terminal-IDE which will install/upgrade emacs in that environment?
Hi Dave! Long time no… anyway, thanks so much for this. Every step worked great on my LG G Pad. While I’m in Emacs, it’s not recognizing Ctrl+Space yet, but I’m sure there’s some configuration file I have to fiddle with somewhere.
For my next step, I don’t know whether to put nxml on it or to try this with my S3 phone. Emacs on my phone!
I’ve used nxml successfully (but with a BT keyboard).
Hi. Thank you for sharing this. I was able to follow every instruction you gave, then when I tried ~/emacs, I got “Loading emacs-lisp/byte-run (compiled; note, source file is newer)…” Nothing happens after waiting for quite sometime that’s why I terminated Terminal IDE. What should I do? Thank you and more power!
I’d love to have this on my phone (not for heavy work, but to have some usable text editor to review latex file I happen to have on the phone..). I tried the prepackaged version : was a pain in the ass (insisted to run in lanscape mode, which is an exruciating pain somewhere on a phone…) then uninstalled it.
Then installed Terminal IDE (went fine) then followed your instructions. This hangs at the launch of ~/emacs : clears screen (except for softkeyboard), maints a line of dashes in the all-but-las line of the (usable part of the) screen, displays “using loadpath (/sdcard/emacs/lisp) n the last line (the cursor is right after the closing paren) an hangs … indefinitely.
Trying to close terminal emulator does not succeds : even after wiping it from the task list, a second consultation of the task list shows it back again. Trying to shutdown all terminals does not succeed either. The only way I found to get rid of it is to reboot the phone.
Any suggestion ? Note : I’m totally ignorant of java and Android : my background is Unix, C, Lisp and R ; I might be a little bit out of my depth here…
I’ve tried recently using the Emacs app from the Play Store, but the software couldn’t be downloaded because http://emacs.zielm.com/ can’t be resolved.
Anyway, I believe that compiling Emacs against the Android environment (to get the paths correct for an app, and correct library links) and running it from inside a nice terminal in Android is no big conceptual problem. So I might try to do this some time to get an Emacs working even in an unrooted Android.
As for a rooted Android, it has been long known that it is possible to install a GNU/Linux distro into a chroot.
But out of interest, I was also interested to get a running Emacs in an unrooted Android.
As a faster solution (without recompiling Emacs against the Android environment), I’ve used the GNURoot app (with GNURoot Wheezy) which allows to use a GNU/Linux distro like Debian in an unrooted Android. There I could start Emacs, as well as ssh to my computers, and hopefully I’ll be able to use TRAMP, too. (I haven’t yet tried this out.)
The GNURoot app does all this by means of a [“PTRACE container”](http://unix.stackexchange.com/a/9188/4319) implemented by [“proot”](http://proot.me/): interception of syscalls and “emulating” what should be done in the different Android and unprivileged environment. (Redirecting paths, faking the root user privileges, etc.)
[It was a while ago when I learned about such projects](https://groups.google.com/d/msg/proot_me/h3rDV8na9kc/4mSCyOsX28UJ).
It’s a pity that source code for GNURoot](https://github.com/corbinlc/gnuroot) seems not to be well documented, so it’s not easy to start hacking with it right away or at least learn how all the things have been compiled and put together from source.
I think it’s a great idea to do a new native Android port of Emacs for use within Terminal IDE — I don’t have the time to do it, but I certainly have the time to test, and will happily update this blog post with a link if/when you have one ready.
In the meantime, http://emacs.zielm.com seems to be back up again. We should probably mirror it, in case the site goes offline permanently.
The download link is broken again. Is there a mirror anywhere?
Nice, brilliant and thanks! Finally got “emacs for Android” working, and it even recognizes org.mode.
I installed everything according to the instructions and it works fine, but:
Terminal IDE does not support UTF-8.
Non-ASCII characters are not displayed.
(It is mentioned in the Playstore description.)
There is a feature request on the project page but the last comment was 1 year ago.
It seems Terminal IDE development is resting.
Nice HowTo. Thx!
Would you also have an idea how to apply your approach to a different terminal app?
More specifically to Jack Palevich’s Terminal Emulator for Android?
I followed your approach for that one, but invoking emacs I get an error message right from the start, saying that the ‘Terminal type’ would not be supported.
I tried putting the terminfo files from http://emacs.zielm.com/data/ into various places on my device and also tried to set TERM and TERMINFO in various ways, but I admittedly I don’t really know what I am doing, and consequentially I cannot get it to work.
Any help would be most appreciated.
For people with emacs crashing on startup – it crashes for me in portrait mode, but not in landscape. Suppose there’s a minimum screen width requirement…
Hi David, which bt keyboard do you use along with your tablet and emacs? Plus, do you know if it is possible to swap the Ctrl key and the Bloc Maiusc key? This is the way I have my keyboard set up on my computer, and it is one of the few things preventing the transition to tablet from happening!
Thanks in advance, and thanks for your article!
I’m using just a generic Logitech BT keyboard, and haven’t had to worry about key swapping.
zielm mirror is down again. Does someone have a mirror that works? Please…
I suggest (temporarily) installing it from the Play store, grabbing the various files, then repackaging them as a zip or tarball. It will be easiest to do on a rooted device, but since the Play package ships with a shell, it will probably be possible to copy the key files from that shell (since it will start as the user that owns the app).
And if anyone does so and puts the files online somewhere, please share the link here.
http://emacs.zielm.com still seems down, and because I really wanted org mode on my android tablet I resorted to the app “Linux Deploy”, which enabled me to install debian on my tablet (and ubuntu on my phone!). From there it’s easy to install emacs, just using apt-get as usual. Linux Deploy let me mount my sd card, and I now use foldersync to sync my org files from my dropbox to my sdcard in Android, and then a little bash script to copy them to my home directory in my linux system (permissions are messed up so I can’t seem to edit the files under linux on the sd card directly without being root). As a side-effect I also have python3 and haskell on my phone and tablet now 😀
Pingback: Update: running Emacs in Android L (Lollipop) | Quoderat
Thank you! This is very helpful!
Followed the instructions exactly and it works great. Now I can edit files on my phone and not lug a laptop around all the time.
I wonder if my desktop .emacs config file will work on the phone, and if it should go in the /sdcard/emacs directory?
I haven’t tried a local .Emacs file yet, but it should work.
Thank you very much. It seems to have worked.