I have built mupdf from source following these steps http://www.mupdf.com/docs/how-to-build-mupdf-for-android. I have integrated it in my app and it is working fine.
I am however facing some issues that I would like input from anyone and I would greatly appreciate
Issue #1
After signing the APK, the app crashes when I try to open any pdf. My guess is some classes are been omitted during the process. I googled and this is the closest answer I came about but it did not work for me. This is how my proguard-rules.pro file looks like
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify
-dontwarn com.squareup.picasso.**
-dontwarn com.android.volley.**
-dontwarn com.nhaarman.listviewanimations.**
-dontwarn android.support.**
-keep class com.artifex.mupdfdemo.** { *; }
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v7.app.** { *; }
-keep interface android.support.v7.app.** { *; }
Issue #2
The second issue is the size of the final signed APK. The size moved from 3.2MB to 10.7MB after including the library. I sought advice from IRC #ghostscript channel but the solution did not solve my problem, may be I missed something in the course of implementation. I was advised to add this
LOCAL_CFLAGS += -DNOCJK
in Core.mk. to exclude fonts from .so. This is how my final Core.mk looked like
LOCAL_PATH := $(call my-dir)
ifdef SUPPORT_GPROOF
include $(CLEAR_VARS)
LOCAL_MODULE := gsso
LOCAL_SRC_FILES := libgs.so
include $(PREBUILT_SHARED_LIBRARY)
endif
include $(CLEAR_VARS)
MY_ROOT := ../..
ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -DARCH_ARM -DARCH_THUMB -DARCH_ARM_CAN_LOAD_UNALIGNED
ifdef NDK_PROFILER
LOCAL_CFLAGS += -pg -DNDK_PROFILER
endif
endif
ifdef SUPPORT_GPROOF
LOCAL_CFLAGS += -DSUPPORT_GPROOF
endif
LOCAL_CFLAGS += -DAA_BITS=8
ifdef MEMENTO
LOCAL_CFLAGS += -DMEMENTO -DMEMENTO_LEAKONLY
endif
ifdef SSL_BUILD
LOCAL_CFLAGS += -DHAVE_OPENSSL
LOCAL_CFLAGS += -DNOCJK
endif
LOCAL_C_INCLUDES := \
../../thirdparty/jbig2dec \
../../thirdparty/openjpeg/libopenjpeg \
../../thirdparty/jpeg \
../../thirdparty/mujs \
../../thirdparty/zlib \
../../thirdparty/freetype/include \
../../source/fitz \
../../source/pdf \
../../source/xps \
../../source/cbz \
../../source/img \
../../source/tiff \
../../scripts/freetype \
../../scripts/jpeg \
../../scripts/openjpeg \
../../generated \
../../resources \
../../include \
../..
ifdef V8_BUILD
LOCAL_C_INCLUDES += ../../thirdparty/$(V8)/include
endif
ifdef SSL_BUILD
LOCAL_C_INCLUDES += ../../thirdparty/openssl/include
endif
LOCAL_MODULE := mupdfcore
LOCAL_SRC_FILES := \
$(wildcard $(MY_ROOT)/source/fitz/*.c) \
$(wildcard $(MY_ROOT)/source/pdf/*.c) \
$(wildcard $(MY_ROOT)/source/xps/*.c) \
$(wildcard $(MY_ROOT)/source/cbz/*.c) \
$(wildcard $(MY_ROOT)/source/gprf/*.c) \
$(wildcard $(MY_ROOT)/source/html/*.c)
LOCAL_SRC_FILES += \
$(MY_ROOT)/source/pdf/js/pdf-js.c \
$(MY_ROOT)/source/pdf/js/pdf-jsimp-mu.c
ifdef SUPPORT_GPROOF
LOCAL_SHARED_LIBRARIES := gsso
endif
LOCAL_LDLIBS := -lm -llog -ljnigraphics
LOCAL_SRC_FILES := $(addprefix ../, $(LOCAL_SRC_FILES))
include $(BUILD_STATIC_LIBRARY)
Any help or guidance will be greatly appreciated.
Thanks