-
Notifications
You must be signed in to change notification settings - Fork 31
/
README
143 lines (91 loc) · 4.59 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# MuPDF Android Viewer
This project is a simplified variant of the full MuPDF Android app that only
supports viewing documents. The annotation editing and form filling features
are not present here.
This project builds both a viewer library and a viewer application.
The viewer library can be used to view PDF and other documents.
The application is a simple file chooser that shows a list of documents on the
external storage on your device, and hands off the selected file to the viewer
library.
## License
MuPDF is Copyright (c) 2006-2017 Artifex Software, Inc.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
## Prerequisites
You need a working Android development environment, consisting of the Android
SKD and the Android NDK. The easiest way is to use Android Studio to download
and install the SDK and NDK.
## Building
Download the project using Git:
$ git clone git://git.ghostscript.com/mupdf-android-viewer.git
Edit the local.properties file to point to your Android SDK directory:
$ echo sdk.dir=$HOME/Android/Sdk > local.properties
If all tools have been installed as per the prerequisites, build the app using
the gradle wrapper:
$ ./gradlew assembleRelease
If all has gone well, you can now find the app APKs in app/build/outputs/apk/,
with one APK for each ABI. There is also a universal APK which supports all
ABIs.
The library component can be found in lib/build/outputs/aar/lib-release.aar.
## Running
To run the app in the android emulator, first you'll need to set up an "Android
Virtual Device" for the emulator. Run "android avd" and create a new device.
You can also use Android Studio to set up a virtual device. Use the x86 ABI for
best emulator performance.
Then launch the emulator, or connect a device with USB debugging enabled:
$ emulator -avd MyVirtualDevice &
Then copy some test files to the device:
$ adb push file.pdf /mnt/sdcard/Download
Then install the app on the device:
$ ./gradlew installDebug
To start the installed app on the device:
$ adb shell am start -n com.artifex.mupdf.viewer.app/.LibraryActivity
To see the error and debugging message log:
$ adb logcat
## Building the JNI library locally
The viewer library here is 100% pure java, but it uses the MuPDF fitz library,
which provides access to PDF rendering and other low level functionality.
The default is to use the JNI library artifact from the Ghostscript Maven
repository.
If you want to build the JNI code yourself, you will need to check out the
'jni' submodule recursively. You will also need a working host development
environment with a C compiler and GNU Make.
Either clone the original project with the --recursive flag, or initialize all
the submodules recursively by hand:
mupdf-mini $ git submodule update --init
mupdf-mini $ cd jni
mupdf-mini/jni $ git submodule update --init
mupdf-mini/jni $ cd libmupdf
mupdf-mini/jni/libmupdf $ git submodule update --init
Then you need to run the 'make generate' step in the libmupdf directory:
mupdf-mini/jni/libmupdf $ make generate
Once this is done, the build system should pick up the local JNI library
instead of using the Maven artifact.
## Release
To do a release you MUST first change the package name!
Do NOT use the com.artifex domain for your custom app!
In order to sign a release build, you will need to create a key and a key
store.
$ keytool -genkey -v -keystore app/android.keystore -alias MyKey \
-validity 3650 -keysize 2048 -keyalg RSA
Then add the following entries to app/gradle.properties:
release_storeFile=android.keystore
release_storePassword=<your keystore password>
release_keyAlias=MyKey
release_keyPassword=<your key password>
If your keystore has been set up properly, you can now build a signed release.
## Maven
The library component of this project can be packaged as a Maven artifact.
The default is to create the Maven artifact in the 'MAVEN' directory. You can
copy thoes files to the distribution site manually, or you can change the
uploadArchives repository in build.gradle before running the uploadArchives
task.
$ ./gradlew uploadArchives
Good Luck!