Using MuPDF in Android Studio.

[UPDATE] This post is no longer valid due to MuPDF licensing, please visit official for complete information

Hello guys, today i’d like to share my experience about building mupdf?for android. I need to use mupdf library to read pdf file in my Android Magazine app.?Building source to executable binary or .so file is a little bit tricky, that’s depends on your host environment whether on Windows, Mac or Linux OS. I’m using Linux Ubuntu 12.04 ,?Android Studio 1.4 , Android SDK and Android NDK r8e. Basically, i didn’t directly import android platform included in mupdf source. I’ve tried that before but there are a lot of error that Android Studio complaining to missing file error, gradle wrapper error etc. So, i tried to build mupdf static library first, create new project in Android Studio and then copy prebuilt static file to jniLibs directory. Maybe this isn’t efficient way but it works for and i hope it helps someone who get problem using mupdf on their own project.

  1. Get the source, go to, in the download section you will get
  2. Open terminal, and run that git command.?When done, go to? mupdf directory.
  3. Make sure your? mupdf?directory contains

    mupdf directory listing

    mupdf directory listing

  4. Make generated directory, by command? make generated
  5. And then? make?. You will see some warning, but as long as it doesn’t stop compiling just wait until finish.mupdf make - using mupdf android studio
  6. Go to /platform/android/ directory.
  7. Copy? . And then uncomment and edit sdk.dir to path where your android sdk located, for example sdk.dir=/home/abhie/android-sdk
  8. Make? to executable file, chmod +x
  9. Run ./
  10. After compiling finish, the static library .so file will be available in /libs/ directory. By default .so file compiled for armeabi-v7a architecture. If you plan to support devices with different architecture, you can change it in /jni/ by uncomment APP_PLATFORM and APP_ABI.
  11. Now create new project?or new module in Android Studio. Make sure your package is?com.artifex.mupdfdemo, if you have different package you will get UnsatisfiedLinkError, because the static library compiled with this package as identifier. If you want to change this update /jni/mupdf.c?line 18-19 to your package name in the same format. And run?./ again.
  12. Copy all source in?src?directory (platform/android/src) to your module. And don’t forget?res/ directory too.?mupdf-copy-android-studio
  13. Edit AndroidManifest.xml, and make sure you register all activity according to /mupdf/platform/android/AndroidManifest.xml .
  14. In your module inside Android Studio, ?create jniLibs?directory?in src/main directory, yes folder name should be exactly?jniLibs.
  15. Copy .so file from /platform/android/libs to jniLibs.
  16. Try rebuild project, if no errors you can run to real devices.


    mupdf running on AXIO pico phone


7 thoughts on “Using MuPDF in Android Studio.

  1. Hello , i am a student in final year .I am working on a project to read pdf files from my app on android. I am developing on Windows 8.1 platform. I have searched the internet on tutorials on how to successfully integrate mupdf in my app but i am hamving a lot of difficulties and errors here and there. i will like to know if you can provide me with a very comprehensible step by step approach on how to finally integrate mupdf on my android app.. thank U in advance.

    1. Hello, you said “working on project read pdf from your android app” but you develop on Windows (instead of ubuntu like my post), right? Once i compile mupdf using windows 7 using cygwin because i need tools like gcc, make etc. So, first i compile mupdf third party, and then compile static library using ndk. once static library (.so file) generated, include it to android jniLibs.

      May i know how far have you develop mupdf using windows platform? I mean, have you compile it or build third party source.

    1. Sorry for super late response.

      How did you get the source? by cloning git repository ( git clone --recursive git:// or by download ( I guess you clone/download the latest version (1.12) which is exclude android sample project.

      They updated the android sample project regarding to license. but you can use docs;a=blob_plain;f=docs/android-sdk.html;hb=26006b55f02c8d0a4a90ffedb45f724798052ef2 how to use it

Leave a Reply

Your email address will not be published. Required fields are marked *