blob: 68bec2456368d91e48f62f3443532cb1c2d5188a [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
66
Michael Meeksdb9ca8e2012-01-20 17:18:35 +000067* Common Errors / Gotchas
68
69lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
70 This (most likely) means that the install quietly failed, and that
71the file is truncated; check it out with adb shell ls -l /data/data/....
72
73
Michael Meeksa0ce2a22012-01-20 09:44:00 +000074* Detailed explanation
75
Tor Lillqvist1371d072013-12-18 12:41:34 +020076Note: the below talk about unit tests is obsolete; we no longer have
77any makefilery etc to build unit tests for Android.
78
Tor Lillqvista9d167b2011-11-11 16:44:18 +020079Unit tests are the first thing we want to run on Android, to get some
Miklos Vajna971228a2013-11-23 16:06:47 +010080idea how well, if at all, the basic LO libraries work. We want to
Tor Lillqvista9d167b2011-11-11 16:44:18 +020081build even unit tests as normal Android apps, i.e. packaged as .apk
82files, so that they run in a sandboxed environment like that of
83whatever eventual end-user Android apps there will be that use LO
84code.
85
Tor Lillqvist05d0bdb2012-01-03 15:27:41 +020086Sure, we could quite easily build unit tests as plain Linux
87executables (built against the Android libraries, of course, not
88GNU/Linux ones), push them to the device or emulator with adb and run
89them from adb shell, but that would not be a good test as the
90environment such processs run in is completely different from that in
91which real end-user apps with GUI etc run. We have no intent to
92require LibreOffice code to be used only on "rooted" devices etc.
Tor Lillqvista9d167b2011-11-11 16:44:18 +020093
94All Android apps are basically Java programs. They run "in" a Dalvik
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030095virtual machine. Yes, you can also have apps where all *your* code is
Tor Lillqvista9d167b2011-11-11 16:44:18 +020096native code, written in a compiled language like C or C++. But also
97also such apps are actually started by system-provided Java
98bootstrapping code (NativeActivity) running in a Dalvik VM.
99
100Such a native app (or actually, "activity") is not built as a
101executable program, but as a shared object. The Java NativeActivity
102bootstrapper loads that shared object with dlopen.
103
Tor Lillqvist30fded62013-03-18 09:24:41 +0200104Anyway, our current "experimental" apps (DocumentLoader,
Viktor Varga9b1e83c2013-08-28 11:19:52 +0200105LibreOffice4Android and LibreOfficeDesktop) are not based on
Tor Lillqvist30fded62013-03-18 09:24:41 +0200106NativeActivity any more. They have normal Java code for the activity,
107and just call out to a single, app-specific native library (called
108liblo-native-code.so) to do all the heavy lifting.