summaryrefslogtreecommitdiff
path: root/docs/android-build-viewer.html
blob: dea1c4fa894cea97656bcfa0a5616ef0f25a038a (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html>
<head>
<title>How to build the MuPDF viewer for Android</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>

<header>
<h1>How to build the MuPDF viewer for Android</h1>
</header>

<nav>
<a href="http://mupdf.com/index.html">ABOUT</a>
<a href="http://mupdf.com/news.html">NEWS</a>
<a href="index.html">DOCUMENTATION</a>
<a href="http://mupdf.com/downloads/">DOWNLOAD</a>
<a href="http://git.ghostscript.com/?p=mupdf.git;a=summary">SOURCE</a>
<a href="https://bugs.ghostscript.com/">BUGS</a>
</nav>

<article>

<h2>Prerequisites</h2>

<p>
You need a working Android development environment, consisting of the Android
SDK and the Android NDK. The easiest way is to use Android Studio to download
and install the SDK and NDK. Make sure that the Android/Sdk/tools and
Android/Sdk/ndk-bundle directories are on your path.

<p>
You also need Oracle's Java JDK (OpenJDK is not compatible with Android).
You also need the Apache Ant build system.
You also need Git, GNU Make, and a C compiler.

<p>
If everything is working, you should be able to run these commands
from the command line:

<blockquote>
	Android SDK tools: android, emulator, and adb.<br>
	Android NDK tools: ndk-build.<br>
	Oracle Java JDK 8: java, and javac.<br>
	Apache Ant: ant.<br>
	Git: git.<br>
	GNU Make: make, or gmake.<br>
	C compiler: cc, gcc, or clang.
</blockquote>

<h2>Building</h2>

<p>
Download the project using Git (and don't forget the --recursive flag):

<pre>
$ git clone --recursive git://git.ghostscript.com/mupdf-android-viewer-mini.git
</pre>

If all tools have been installed as per the prerequisites, build the app
using make:

<pre>
$ make
</pre>

The makefile will take care of setting up the android project and
configuration files. This is of course assuming that you have set
up the pre-requisites properly.

<h2>Running</h2>

<p>
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.

<p>
Then launch the emulator, or connect a device with USB debugging enabled:

<pre>
$ emulator -avd MyVirtualDevice &
</pre>

<p>
Then copy some test files to the device:

<pre>
$ adb push file.pdf /mnt/sdcard/Download
</pre>

<p>
Then install the app on the device:

<pre>
$ make install
</pre>

<p>
In order to build, install, and launch the app in one step:

<pre>
$ make run
</pre>

<p>
To see the error and debugging message log:

<pre>
$ adb logcat
</pre>

<h2>Release</h2>

<p>
To release you <b>MUST</b> first change the package name.
Do <b>NOT</b> use the com.artifex domain for your custom app!

<pre>
$ mv src/com/artifex src/com/YourCompanyName
</pre>

<p>
Change all references to com.artifex.mupdf.mini into
com.YourCompanyName.mupdf.mini in the Java source files and XML resources.

<p>
In order to sign a release build, you will need to create a key and a key store.

<pre>
$ keytool -genkey -v -keystore android.keystore -alias MyKey \
    -validity 3650 -keysize 2048 -keyalg RSA
</pre>

<p>
Then add the following entries to local.properties:

<pre>
key.store=android.keystore
key.store.password=<i>your keystore password</i>
key.alias=MyKey
key.alias.password=<i>your key password</i>
</pre>

<p>
If your keystore has been set up properly, you can now build a release APK.

<pre>
$ make release
</pre>

<p>
Good Luck!

</article>

<footer>
<a href="http://artifex.com"><img src="artifex-logo.png" align="right"></a>
Copyright &copy; 2006-2017 Artifex Software Inc.
</footer>

</body>
</html>