MuPdf Android JNI library is very large
Asked Answered
M

1

6

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?

Mescaline answered 29/4, 2015 at 21:57 Comment(0)
S
6

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

Shenitashenk answered 30/4, 2015 at 0:33 Comment(2)
Wow, I would have never thought that the *.so file contains resources (fonts etc.). Thanks for that hint! We do have at least Chinese and Korean users, but I think it's still okay to strip the CJK fonts from the package, since Document Viewer has a setting for custom fonts (that are then injected into mupdf). I will try your suggestion later today and mark your answer as solution if everything works as expected.Mescaline
(Just remembered that they are not resources as in files. If you remove the fonts from file tree, there's a hardcoded byte array backup in code.)Shenitashenk

© 2022 - 2024 — McMap. All rights reserved.