[droid] splash: adjust progressbar color
[vuplus_xbmc] / docs / README.android
1 TOC
2 1. Introduction
3 2. Installing and setting up the Android environment
4 3. Getting the source code
5 4. Installing the required Ubuntu packages
6 5. How to compile
7 6. Installing XBMC in an Android system
8 7. Running and debugging XBMC in an Android system
9 8. Architecture
10 9. Useful Commands
11
12 -----------------------------------------------------------------------------
13 1. Introduction
14 -----------------------------------------------------------------------------
15
16 We currently recommend Ubuntu Natty (11.04) or later. Current work has been
17 done here. Additionally, building from OSX Snow Leopard is working.
18
19 NOTE TO NEW USERS: All lines that are prefixed with the '#'
20 character are commands that need to be typed into a terminal window /
21 console (similar to the command prompt for Windows). Note that the '#'
22 character itself should NOT be typed as part of the command.
23
24 -----------------------------------------------------------------------------
25 2. Installing the required Ubuntu packages
26 -----------------------------------------------------------------------------
27 These are the minimum packages necessary for building XBMC. Non-Ubuntu
28 users will need to get the equivalents.
29
30    # sudo apt-get install build-essential default-jdk git curl autoconf \
31        unzip zip zlib1g-dev gawk gperf cmake
32
33 If you run a 64bit operating system you will also need to get ia32-libs
34
35    # sudo apt-get install ia32-libs
36
37
38 -----------------------------------------------------------------------------
39 3. Installing and setting up the Android environment
40 -----------------------------------------------------------------------------
41
42 To develop XBMC for Android the Android SDK and NDK are required.
43 Because the Android NDK is lacking support for wide characters (wchar_t)
44 which XBMC relies on for Unicode implementation, a third-party NDK
45 from Crystax is being used.
46
47 --------------------------------------------------------------------
48 3.1. Getting the Android SDK and NDK
49 --------------------------------------------------------------------
50
51 To get the Android SDK, go to http://developer.android.com/sdk and
52 download the latest version for your operating system. The Crystax NDK
53 can be downloaded from http://www.crystax.net/en/android/ndk
54
55 [NOTICE] Compiling XBMC for Android requires at least Crystax Android NDK
56          Revision 7b. Crystax Android NDK Revision 7 and earlier do not work
57          properly for our cause. The corresponding Crystax NDK version
58          is android-ndk-r7-crystax-5. Do not use the standard Android NDK.
59          
60 After downloading the SDK and NDK extract the files contained in the
61 archives to your harddisk.
62
63 Make sure you have a recent JRE and JDK installed otherwise the
64 Android SDK will not work.
65
66 --------------------------------------------------------------------
67 3.2. Installing Android SDK packages
68 --------------------------------------------------------------------
69
70 After having extracted the Android SDK to <android-sdk> you need to
71 install some android packages using the Android SDK Manager:
72
73    # cd <android-sdk>/tools
74    # ./android update sdk -u -t platform,platform-tool
75
76 --------------------------------------------------------------------
77 3.3. Setup the Android toolchain
78 --------------------------------------------------------------------
79
80 To be able to compile XBMC and the libraries it depends on for the
81 Android platform you first need to setup an Android toolchain using
82 the Android NDK which you earlier extracted to <android-ndk>. The
83 following commands will create a toolchain suitable for the most
84 common scenario.
85 The --install-dir option (and therefore the <android-toolchain> value)
86 specifies where the resulting toolchain should be installed (your choice).
87
88    # cd <android-ndk>
89    # ls platforms
90    # cd build/tools
91    # ./make-standalone-toolchain.sh --ndk-dir=../../ \
92      --install-dir=<android-toolchain>/android-9 --platform=android-9
93
94 ATTENTION FOR X86 BUILDS - THIS DOES NOT APPLY TO 99% OF BUILDS:
95 If you want to build for the x86 platform there is a flaw in the mentioned
96 NDK. See http://code.google.com/p/android/issues/detail?id=19851 which results
97 in linker errors mentioning "sigsetjmp and siglongjmp".
98 In that case you have to download the libc.tar.bz2 from that google issue
99 entry:
100
101 http://android.googlecode.com/issues/attachment?aid=198510003000&name=libc.tar.bz2&token=6uNpHc1v8ixmVOTq3y6-ohUfb0o%3A1341156659947
102
103 And extract it to <android-toolchain>/android-<x>/sysroot/usr/lib/ and overwrite
104 the libc.so there. (where <android-toolchain>/android-<x>/ is the path you have given on the
105 --install-dir option above)
106
107 --------------------------------------------------------------------
108 3.4. Create a (new) debug key to sign debug APKs
109 --------------------------------------------------------------------
110
111   All packages must be signed. The following command will generate a
112   self-signed debug key. If the result is a cryptic error, it
113   probably just means a debug key already existed, no cause for alarm.
114
115   # keytool -genkey -keystore ~/.android/debug.keystore -v -alias \
116       androiddebugkey -dname "CN=Android Debug,O=Android,C=US" -keypass \
117       android -storepass android -keyalg RSA -keysize 2048 -validity 10000
118
119 -----------------------------------------------------------------------------
120 4. Getting the source code
121 -----------------------------------------------------------------------------
122
123    # cd $HOME
124    # git clone git://github.com/xbmc/xbmc.git xbmc-android
125    # cd xbmc-android
126    # git submodule update --init addons/skin.touched
127
128 -----------------------------------------------------------------------------
129 5. How to compile
130 -----------------------------------------------------------------------------
131
132 Compiling XBMC for Android consists of compiling the libraries XBMC depends
133 on with the Android toolchain and creating an Android Application Package
134 (APK) which can be installed in an Android system.
135
136 --------------------------------------------------------------------
137 5.1. Building dependencies
138 --------------------------------------------------------------------
139
140    # cd $HOME/xbmc-android/tools/android/depends
141    # ./bootstrap
142    # ./configure --help
143
144    Run configure with the correct settings for you local configuration.
145
146    Anyone working on the dependencies themselves will want to set the
147    environment variables specified in ~/.bashrc or similar, to avoid
148    having to input these with each configure. 
149
150    # make -j <jobs>
151
152    This build was designed to be massively parallel. Don't be afraid to
153    give it a 'make -j20' or so.
154
155    Verify that all deps built correctly (it will tell you so) before
156    continuing. You will get crazy build errors otherwise.
157
158 --------------------------------------------------------------------
159 5.2. Building XBMC
160 --------------------------------------------------------------------
161
162    # cd $HOME/xbmc-android
163    # make -C tools/android/depends/xbmc
164
165    After the first build (assuming bootstrap and configure are successful),
166    subsequent builds can be run with a simple 'make' and 'make apk'.
167
168 -----------------------------------------------------------------------------
169 6. Installing XBMC in an Android system
170 -----------------------------------------------------------------------------
171
172 To install XBMC through the previously built APK in an Android system you can
173 either install it on a real device (smartphone/tablet/...) running Android
174  >= 2.3.x.
175
176 --------------------------------------------------------------------
177 6.1. Installing XBMC on the Android device
178 --------------------------------------------------------------------
179
180 Make sure your Android device is connected to your computer through
181 USB. Furthermore you have to enable the following option in your
182 device's Android settings:
183
184   - Applications
185     [X] Unknown sources
186
187    # cd $HOME/xbmc-android/tools/android/packaging
188    # adb devices
189    # adb -s <device-id> install -r images/xbmcapp-debug.apk
190       
191 The <device-id> can be retrieved from the list returned by the
192 "adb devices" command and is the first value in the row representing
193 your device.
194
195 -----------------------------------------------------------------------------
196 7. Running and debugging XBMC in an Android system
197 -----------------------------------------------------------------------------
198
199 After installing XBMC's APK in an Android system you can start it using its
200 Launcher icon in Android's Application Launcher.
201
202 --------------------------------------------------------------------
203 7.1. Debugging XBMC
204 --------------------------------------------------------------------
205
206 To be able to see what is happening while running XBMC you first need
207 to enable USB debugging in your Android settings (this is already done
208 when using the emulator):
209
210   - Applications
211     [X] Unknown sources
212      -  Development
213       [X] USB debugging
214
215 To access the log output of your Android system run (the -s parameter
216 and the <device-id> may not be needed when using the Android emulator)
217
218   # adb -s <device-id> logcat
219
220
221 --------------------------------------------------------------------
222 7.2. GDB
223 --------------------------------------------------------------------
224
225 GDB can be used to debug, though the support is rather primitive. Rather than
226 using gdb directly, you will need to use ndk-gdb which wraps it. Do NOT trust
227 the -p/--project switches, as of ndk7b they do not work. Instead you will need
228 to cd to tools/android/packaging/xbmc and execute it from there.
229
230   # ndk-gdb --start --delay=0
231
232 This will open the installed version of XBMC and break. The warnings can be
233 ignored as we have setup the appropriate paths already.
234
235 --------------------------------------------------------------------
236 8. Architecture
237 --------------------------------------------------------------------
238
239 During the early days of the android port, xbmc was launched via a stub lib
240 that then dlopen'd libxbmc. This was done to get around bionic's poor handling
241 of shared libs. We now compile everything into libxbmc itself so that it has
242 no runtime dependencies beyond system libs. Done this way, we're able to launch
243 into libxbmc directly.
244
245 But we still hit Bionic's loader's deficiencies when we dlopen a lib. There are
246 two main issues to overcome for loading:
247
248 1. Bionic imports all symbols for a lib as soon as it is loaded, and it will
249 refuse to open a lib if it has a single unresolved symbol
250
251 2. It does not search recursively during the resolve. So if liba depends on
252 libb, dlopen'ing liba will _not_ pull in missing symbols from libb. This is
253 particularly nasty considering #1.
254
255 To work-around these problems we use our own recursive loader in place of
256 dlopen. This loader mimics expected behavior. Using the example above, loading
257 libb before liba will mean that everything will resolve correctly.
258
259 Additionally, Android does not use versioned solibs. libfoo.so.1 which is
260 typical on linux would not be found by the loader. This means that we must
261 strip the SONAME and NEEDED values out of the libs as well as changing the
262 filenames themselves. The cleaner solution would be to patch libtool/cmake/etc
263 to not add versioning in the first place. For now, we use the brute-force
264 approach of modifying the binary and blanking out the versions.
265
266 See here for more info:
267 http://www.bernawebdesign.ch/byteblog/2011/11/23/creating-non-versioned-shared-libraries-for-android/
268
269 As a final gotcha, all libs must be in the form of ^lib.*so$ with no
270 exceptions (they won't even install otherwise), and the soname must match.
271 So we have to do some renaming to get some of our self-built libs loaded.
272
273 Development:
274 Typical android native activities are built with ndk-build which is a wrapper
275 around Make. It would be a nightmare to port our entire buildsystem over, so
276 instead we build as usual then package ourselves. It may be beneficial to use
277 ndk-build to do the actual packaging, but for now its behavior is emulated.
278
279 ABI:
280 Presently we are targeting armv7a+neon for arm, and i686 for x86. Note that x86
281 builds successfully but has not been tested.
282
283 --------------------------------------------------------------------
284 9. Useful Commands
285 --------------------------------------------------------------------
286
287 Below are a few helpful commands when building/debugging. These assume that pwd
288 is 'tools/android/packaging' and that the proper sdk/ndk paths are set.
289
290 -Install a new build over the existing one
291   # adb -e install -r images/xbmcapp-debug.apk
292
293 -Launch XBMC on the emulator without the GUI
294   # adb shell am start -a android.intent.action.MAIN -n org.xbmc.xbmc/android.app.NativeActivity
295
296 -Kill a misbehaving XBMC
297   # adb shell ps | grep org.xbmc | awk '{print $2}' | xargs adb shell kill
298
299 -Filter logcat messages by a specific tag (e.g. "XBMC")
300   # adb logcat -s XBMC:V
301   
302 -Enable CheckJNI (BEFORE starting the application)
303   # adb shell setprop debug.checkjni 1
304