summaryrefslogtreecommitdiff
path: root/docs/android-build-library.html
blob: f8a0e1c773c7bfb9b3d8333d2d0ec9c8a1666c1b (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
<!DOCTYPE html>
<html>
<head>
<title>How to build the MuPDF library 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 library 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/">Downloads</a>
<a href="http://git.ghostscript.com/?p=mupdf.git;a=summary">Source</a>
<a href="https://bugs.ghostscript.com/">Bugs</a>
</nav>

<article>

<p>
The MuPDF library in Android is based on JNI to access the native C library
through a layer of Java classes. The MuPDF Java library provides platform
independent (i.e. both Android and desktop Java) low level access to MuPDF
functionality.

<p>
The MuPDF Java library does not provide any Android specific components
or widgets -- build those yourself or use one of the example viewers as
a start!

<p>
In order to use the MuPDF library in Android, you must thus add two components
to your build system: the JNI library, and the Java library.

<h2>Setting up the MuPDF subproject</h2>

<p>
Set up your Android project as you wish, and then add the mupdf repository
as a directory somewhere in your project. If you're using git, you can
use a submodule:

<pre>
$ git submodule add git://git.ghostscript.com/mupdf.git libmupdf
$ cd libmupdf
$ git submodule update --init
</pre>

<p>
You can also unpack a release tarball archive in your source directory.

<p>
We'll assume you name the mupdf project directory 'libmupdf'.

<p>
Use your host compiler to run the 'generate' step in the mupdf project:

<pre>
$ make -C libmupdf generate
</pre>

<h2>Adding the JNI library</h2>

<p>
Add an NDK-build step to your project, using the Android.mk file from mupdf.

<p>
Add an externalNativeBuild section in the android section in the
build.gradle file:

<pre>
android {
	externalNativeBuild {
		ndkBuild.path 'libmupdf/platform/java/Android.mk'
	}
}
</pre>

<h2>Adding the Java library</h2>

<p>
You'll also need to include the Java classes that bind to the JNI library.

<p>
Add the 'libmupdf/platform/java/src' directory to the list of source
directories in the build.gradle file:

<pre>
android {
	sourceSets {
		main {
			java.srcDirs 'src/main/java', 'libmupdf/platform/java/src'
		}
	}
}
</pre>

</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>