I have gotten the MathJax app for Android working in standalone form — that is, with MathJax included in the app package, no need for an internet connection for it to work. Here are links to the files:
- Install package: MathJaxAppFull.apk
- Local MathJax in
assetsdirectory (ZIP file): assets.zip
- Apache v2.0 License and Notice
I have also updated the links to the online version of the app (the previous version, which requires an internet connection so that it can get MathJax from the CDN) — just to have everything in one place, here are the links to the files for that app:
- Install package: MathJaxAppOnline.apk
- Apache v2.0 License and Notice
As usual, you can download the files with right-click -> “Save Link As…”.
Again, some programming notes: As I indicated in an earlier post, one thing I was trying to sort out in developing the standalone app was whether to use application assets or raw resources. I saw some advantages to raw resources because of the internationalization mechanism, but it turns out that the mechanism itself causes some problems with subdirectories, so I had to use assets. I was still having some trouble loading the scripts from the assets directory, though, and I thought I might have to overload the
Toast notification, for diagnostic purposes, but what I discovered was that the problem was more basic than that. Files in the assets directory are accessed using
file: URLs, which are not a problem for MathJax, but the standard way of loading a configuration for MathJax uses a URL parameter in the form “
?config=...” — it turns out that
file: URLs and URL parameters just don’t play well together at all. So I had to use
<script type="x-mathjax-config"> tags in the HTML in order to load the configuration. This turned out to be a good thing in the long run — it gave me the flexibility in the configuration to pick and choose what was needed for the
WebView and scale down the local MathJax installation. I got the MathJax directory down to about 1.4Mb total (in uncompressed form — that’s down from 20.8Mb for the full installation). This made for a nice, reasonably lean standalone app (the compressed APK is about 1.0Mb). The online version is still much more lightweight (its APK is about 155Kb) and is still available for those who prefer it.
One other point: The standalone app uses the HTML-CSS output mode for MathJax — the other option for the
WebView would have been SVG output. I prefer the glyphs in the OTF fonts used by the
WebView for HTML-CSS output because they are a bit lighter than the glyphs in the SVG output. There are some long-term advantages to SVG in terms of browser standards, but I don’t expect the app to go that long without needing an update anyway — MathJax version 2.1 is already in the works. I can re-evaluate this choice when I work on the next update.
Update: As seen in the comments below, this app has a problem in Android v4.4 KitKat. After too long of a delay, I finally have a fix, and it turns out to be really simple. I will put up a new post and update the code very soon.
Update 2: The APK and
MainActivity.java source code file at the links above have been updated with the KitKat fix. See this post for information about the fix. I have also updated the assets ZIP file with MathJax version 2.3, and updated the information in the license notice file.