blob: 9d022a719f80f87155643fb374885bd9128f03b2 [file] [log] [blame]
Tor Lillqvista9d167b2011-11-11 16:44:18 +02001Android-specific notes
2
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +03003Note that this document has not necessarily been updated to match
Tor Lillqvist2462aa62014-02-21 22:37:47 +02004reality...
5
6For instructions on how to build for Android, see README.cross.
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +03007
8* Getting something running on an emulated device
Michael Meeksa0ce2a22012-01-20 09:44:00 +00009
10 Create an AVD in the android UI, don't even try to get
11the data partition size right in the GUI, that is doomed to producing
12and AVD that doesn't work. Instead start it from the console:
13
Miklos Vajna09189c32012-11-09 15:12:47 +010014 LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500
15
16In order to have proper acceleration, you need the 32-bit libGL.so:
17
18 sudo zypper in Mesa-libGL-devel-32bit
Michael Meeksa0ce2a22012-01-20 09:44:00 +000019
20 Where <Name> is the literal name of the AVD that you entered.
Michael Meeksa0ce2a22012-01-20 09:44:00 +000021
22 Then:
23
Michael Meeks739252d2012-02-27 14:16:54 +000024 make cmd cmd=bash
Michael Meeksa0ce2a22012-01-20 09:44:00 +000025 cd android/qa/sc
26 make clean all install
27 make run ; adb shell logcat
28
Tor Lillqvistb58498f2012-05-17 10:09:22 +030029 And if all goes well - you should have some nice unit test output to
30enjoy. After a while of this loop you might find that you have lost a lot of
31space on your emulator's or device's /data volume. If using the emulator, you
32can do:
Michael Meeks56db0772012-01-20 10:19:42 +000033
Tor Lillqvistb58498f2012-05-17 10:09:22 +030034 adb shell stop; adb shell start
35
36but on a (non-rooted) device you probably just need to reboot it. On the other
37hand, this phenomenon might not happen on actual devices.
Michael Meeks56db0772012-01-20 10:19:42 +000038
39 and continue onwards & upwards.
Michael Meeksa0ce2a22012-01-20 09:44:00 +000040
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030041* What about using a real device?
42
43 That works fine, too. You won't be able to use the "adb shell
44stop" and "adb shell start" commands to do anything, as far as I
45know. But don't seem to be necessary on a real device anyway?
46
Michael Meeks0eef5f62012-01-20 12:08:01 +000047* Debugging
48
Tor Lillqvist1371d072013-12-18 12:41:34 +020049 Some versions of the NDK had a broken gdb in the way that it can see
Michael Meeks0eef5f62012-01-20 12:08:01 +000050symbols only for shlibs that were already loaded when the debuggee was
51attached, so you need to carefully guess where to put:
52
53 fprintf(stderr, "Sleeping NOW!\n"); ::sleep(20);
54
55 into the code; and when you see that in logcat, you have time
56to run: ndk-gdb and it will attach the process.
57
Michael Meekse74a3582012-01-23 17:08:55 +000058 thread 12 # or perhaps 13
59 backtrace
60
61 may show you the native code trace.
62
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030063 In r8b the ndk-gdb seems to work a bit better, and I think it isn't
64necessary to use the mingw-and-ndk ndb-gdb any longer.
65
Jan Holesovskyd641b542014-07-14 16:54:11 +020066* Getting the symbols
67
68In order to be able to debug, you also need the symbols. Currently they are
69stripped using a $(STRIP) call in android/Bootstrap/Makefile.shared ; make
70sure you change it only to 'cp'.
71
72But then you need to limit the size of the resulting binary by other means,
73that is strip most of the symbols (but the interesting ones) already during
74the build. For that, use something like
75
76--enable-dbgutil
77--enable-selective-debuginfo="sal/"
78
79in your autogen.input (but of course limit the --enable-selective-debuginfo
80only to directories / libraries that are interesting to you).
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030081
Michael Meeksdb9ca8e2012-01-20 17:18:35 +000082* Common Errors / Gotchas
83
84lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
85 This (most likely) means that the install quietly failed, and that
86the file is truncated; check it out with adb shell ls -l /data/data/....
87
88
Michael Meeksa0ce2a22012-01-20 09:44:00 +000089* Detailed explanation
90
Tor Lillqvist1371d072013-12-18 12:41:34 +020091Note: the below talk about unit tests is obsolete; we no longer have
92any makefilery etc to build unit tests for Android.
93
Tor Lillqvista9d167b2011-11-11 16:44:18 +020094Unit tests are the first thing we want to run on Android, to get some
Miklos Vajna971228a2013-11-23 16:06:47 +010095idea how well, if at all, the basic LO libraries work. We want to
Tor Lillqvista9d167b2011-11-11 16:44:18 +020096build even unit tests as normal Android apps, i.e. packaged as .apk
97files, so that they run in a sandboxed environment like that of
98whatever eventual end-user Android apps there will be that use LO
99code.
100
Tor Lillqvist05d0bdb2012-01-03 15:27:41 +0200101Sure, we could quite easily build unit tests as plain Linux
102executables (built against the Android libraries, of course, not
103GNU/Linux ones), push them to the device or emulator with adb and run
104them from adb shell, but that would not be a good test as the
105environment such processs run in is completely different from that in
106which real end-user apps with GUI etc run. We have no intent to
107require LibreOffice code to be used only on "rooted" devices etc.
Tor Lillqvista9d167b2011-11-11 16:44:18 +0200108
109All Android apps are basically Java programs. They run "in" a Dalvik
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +0300110virtual machine. Yes, you can also have apps where all *your* code is
Tor Lillqvista9d167b2011-11-11 16:44:18 +0200111native code, written in a compiled language like C or C++. But also
112also such apps are actually started by system-provided Java
113bootstrapping code (NativeActivity) running in a Dalvik VM.
114
115Such a native app (or actually, "activity") is not built as a
116executable program, but as a shared object. The Java NativeActivity
117bootstrapper loads that shared object with dlopen.
118
Tor Lillqvist30fded62013-03-18 09:24:41 +0200119Anyway, our current "experimental" apps (DocumentLoader,
Viktor Varga9b1e83c2013-08-28 11:19:52 +0200120LibreOffice4Android and LibreOfficeDesktop) are not based on
Tor Lillqvist30fded62013-03-18 09:24:41 +0200121NativeActivity any more. They have normal Java code for the activity,
122and just call out to a single, app-specific native library (called
123liblo-native-code.so) to do all the heavy lifting.