Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MuPdf Android JNI library is very large

As described here (https://github.com/sufficientlysecure/document-viewer/issues/88) we're facing the problem that the JNI library that is part of the MuPdf Android demo is really large. In this case, this affects the size of the Document Viewer app (https://f-droid.org/repository/browse/?fdid=org.sufficientlysecure.viewer). The *.so files in the APK are more than 12 MB in size!

Before we updated MuPdf to the latest version a few months ago (i.e. version 2.5 and earlier of Document Viewer), the *.so files accounted for only 3,9 MB each.

Can you explain this increase of literally 300%? Is there anything we can change to compress our JNI libs further?

like image 329
thomas Avatar asked Apr 29 '15 21:04

thomas


1 Answers

1) Splitting .apk

NDK support in AndroidStudio and choosing between Android Studio and Eclipse

2) Minimizing MuPDF

It is absolutely essential you build the library from sources yourself and generate multiple .sos based on platform (the sources contain strong hints on how to achieve this so I'll not go into details).

Then try adding

LOCAL_CFLAGS += -DNOCJK

in Core.mk to exclude fonts from the .so (that's right, the 9 MB worth of fonts from resources\fonts\droid will now be stripped from the library).

Just went from 9266 kB to 2155 kB unpacked.

EDIT: Then again it depends what your target market is. You might need to keep those in. CJK = Chinese, Japanese, Korean

like image 70
Eugen Pechanec Avatar answered Oct 28 '22 11:10

Eugen Pechanec