Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7639 views
1
To build/debug android build.
2
3
1) Download the android sdk, and install it. These instructions have been
4
written with r14 (the latest version at time of writing) of the SDK in mind;
5
other versions may give problems. On windows r14 unpacked as:
6
7
C:\Program Files (x86)\Android\android-sdk
8
9
on Macos an older version installed as:
10
11
/Library/android-sdk-mac_x86
12
13
on Linux install it as:
14
15
mkdir ~/android-sdk
16
cd ~/android-sdk
17
tar ~/Downloads/android-sdk_r20.0.3-linux.tgz
18
19
Whatever directory it unpacks to, ensure that both the 'tools' and
20
'platform-tools' directories inside it have been added to your PATH.
21
22
2) Download the android ndk, and unpack it. These instructions were written
23
with NDK r6b (the latest version at the time of writing) in mind, but the
24
build has now been tweaked to work with r10b. Other versions may give problems.
25
26
It's important that you use the correct NDK for the target platform. If you're
27
targeting a 32-bit platform (such as "ARM EABI v7a" or "Intel x86 Arm") then
28
you MUST use the 32-bit target NDK. If you get UnsatisfiedLinkError when
29
opening a document in MuPDF, then you've tried to use the 64-bit target NDK
30
with a 32-bit target!
31
32
On windows I unpacked it as:
33
34
C:\android-ndk-r10b
35
36
on Macos an older version unpacked as:
37
38
/Library/android-ndk-r5
39
40
on Linux as:
41
42
mkdir ~/android-ndk
43
cd ~/android-ndk
44
tar jxvf ~/Downloads/android-ndk32-r10b-linux-x86.tar.bz2
45
46
It is very important that you should unpack it to a directory with no
47
spaces in the name! (Don't be tempted to put it in C:\Program Files etc)
48
49
Ensure that that directory is also added to your PATH.
50
51
3) On windows, to use the ndk, you *must* be running under cygwin. This means
52
you need to install Cygwin 1.7 or greater now.
53
54
[ In version r5 of the ndk, when running under cygwin, there were ]
55
[ bugs to do with the automatic conversion of dependencies from DOS ]
56
[ format paths to cygwin format paths. The 2 fixes can be found in: ]
57
[ ]
58
[ <http://groups.google.com/group/android-ndk/msg/b385e47e1484c2d4> ]
59
[ ]
60
[ Use the latest version and there should not be a problem. ]
61
62
4) If the SDK has not popped up a window already, bring up a shell, and run
63
'android' (or android.bat on cygwin/windows). You should now have a window
64
with a graphical gui for the sdk. From here you can install the different SDK
65
components for the different flavours of android. Download them all -
66
bandwidth and disk space are cheap, right? Make sure you get at least
67
the API level 11 as this is the current dependency for mupdf.
68
69
5) In new versions of the GUI there is a 'Tools' menu from which you can
70
select 'Manage AVDs...'. In old versions, go to the Virtual Devices entry
71
on the right hand side. You need to create yourself an emulator image to
72
use. Click 'New...' on the right hand side and a window will appear. Fill
73
in the entries as follows:
74
75
Name: FroyoEm
76
Target: Android 2.2 - API Level 8
77
CPU/ABI: ARM (armeabi) (If this option exists)
78
SD card: Size: 1024MiB
79
Skin: Resolution: 480x756 (756 just fits my macbook screen, but 800 may
80
be 'more standard')
81
82
Click 'Create AVD' (on old versions you may have to wait for a minute or
83
so while it is prepared. Now you can exit the GUI.
84
85
6) You will need a copy of the JDK installed. See
86
<http://www.oracle.com/technetwork/java/javase/downloads/>. When this
87
installs, ensure that JAVA_HOME is set to point to the installation
88
directory.
89
90
7) You will need a copy of Apache ANT installed.
91
See <http://ant.apache.org/>. Ensure that ANT_HOME is set to point to
92
the top level directory, and that ANT_HOME/bin is on the PATH.
93
94
8) Now we are ready to build mupdf for Android. Check out a copy of MuPDF
95
(but you've done that already, cos you're reading this, right?).
96
97
9) You will also need a copy of mupdf's thirdparty libraries. If you are
98
using git, make sure to do a git submodule update --init from the top of
99
the build tree. Older versions packaged this source code in a .zip-file
100
(see the source code link on http://mupdf.com/). Unpack the contents of
101
this into a 'thirdparty' directory created within the mupdf directory
102
(i.e. at the same level as fitz, pdf, android etc).
103
104
10) Finally, you will need a copy of a 'generated' directory. This is not
105
currently available to download.
106
107
The normal mupdf build process involves running some code on the host
108
(the machine on which you are compiling), rather than the target (the
109
machine/device on which you eventually want to run mupdf). This code
110
repacks various bits of information (fonts, CMAPs etc) into a more
111
compact and usable form.
112
113
Unfortunately, the android SDK does not provide a compiler for the host
114
machine, so we cannot run this step automatically as part of the android
115
build. You will need to generate it by running a different build, such
116
as the windows or linux native builds.
117
118
We do not make a snapshot of the generated directory available to
119
download as the contents of this directory change frequently, and we'd
120
have to keep multiple versions on the website. We assume that anyone
121
capable of building for android is capable of doing a normal hosted
122
build.
123
124
On windows (where you are using cygwin), or on linux/macos, this can be
125
as simple as running 'make generate' in the top level directory.
126
127
11) Change into mupdf's android directory. Copy the
128
android/local.properties.sample file to be android/local.properties and
129
change the sdk path there as appropriate. This should be the only bit of
130
localisation you need to do.
131
132
12) Change into the android directory (note, the android directory, NOT
133
the android/jni directory!), and execute (in a Cygwin window on Windows!):
134
135
ndk-build
136
137
This should build the native code portion.
138
139
If this dies with an error in thirdparty/jbig2/os_types.h load this
140
file into an editor, and change line 43 from:
141
142
#else
143
144
to
145
146
#elif !defined(HAVE_STDINT_H)
147
148
and this should solve the problem.
149
150
13) Then execute:
151
152
ant debug
153
154
or on windows under cygwin:
155
156
ant.bat debug
157
158
This should build the java wrapper.
159
160
14) Now start the emulator by executing:
161
162
emulator -avd FroyoEm
163
164
This will take a while to full start up (be patient).
165
166
15) We now need to give the demo file something to chew on, so let's copy
167
a file into the SD card image of the emulator (this should only need to be
168
done once). With the emulator running type:
169
170
adb push ../../MyTests/pdf_reference17.pdf /mnt/sdcard/Download/test.pdf
171
172
(where obviously ../../MyTests/pdf_reference17.pdf is altered for your
173
machine, and under Windows, should start c:/ even if invoked from cygwin)
174
(adb lives in <sdk>/platform-tools if it's not on your path).
175
176
16) With the emulator running (see step 14), execute
177
178
ant debug install
179
180
('ant.bat debug install' on Windows) and that will copy MuPDF into the
181
emulator where you can run it from the launchpad screen.
182
183
17) To see debug messages from the emulator (including stdout/stderr from
184
our app), execute:
185
186
adb logcat
187
188
Good luck!
189
190