blob: 9ae7fd3ec04f7aa5f91906f9f4d1899823998d6c [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
xjcl04a65e22014-08-04 21:33:49 +020012an AVD that doesn't work. Instead start it from the console:
Michael Meeksa0ce2a22012-01-20 09:44:00 +000013
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
Jan Holesovskyc862be02014-10-13 16:51:08 +020049 Install the .apk to the device, start the application, and:
50
51 cd android/experimental/LOAndroid3
52 <android-ndk-r9d>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb
53
Tor Lillqvist1371d072013-12-18 12:41:34 +020054 Some versions of the NDK had a broken gdb in the way that it can see
Michael Meeks0eef5f62012-01-20 12:08:01 +000055symbols only for shlibs that were already loaded when the debuggee was
56attached, so you need to carefully guess where to put:
57
58 fprintf(stderr, "Sleeping NOW!\n"); ::sleep(20);
59
60 into the code; and when you see that in logcat, you have time
61to run: ndk-gdb and it will attach the process.
62
Michael Meekse74a3582012-01-23 17:08:55 +000063 thread 12 # or perhaps 13
64 backtrace
65
66 may show you the native code trace.
67
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030068 In r8b the ndk-gdb seems to work a bit better, and I think it isn't
69necessary to use the mingw-and-ndk ndb-gdb any longer.
70
Jan Holesovskyd641b542014-07-14 16:54:11 +020071* Getting the symbols
72
73In order to be able to debug, you also need the symbols. Currently they are
74stripped using a $(STRIP) call in android/Bootstrap/Makefile.shared ; make
75sure you change it only to 'cp'.
76
77But then you need to limit the size of the resulting binary by other means,
78that is strip most of the symbols (but the interesting ones) already during
79the build. For that, use something like
80
81--enable-dbgutil
82--enable-selective-debuginfo="sal/"
83
84in your autogen.input (but of course limit the --enable-selective-debuginfo
85only to directories / libraries that are interesting to you).
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030086
Michael Meeksdb9ca8e2012-01-20 17:18:35 +000087* Common Errors / Gotchas
88
89lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
90 This (most likely) means that the install quietly failed, and that
91the file is truncated; check it out with adb shell ls -l /data/data/....
92
93
Michael Meeksa0ce2a22012-01-20 09:44:00 +000094* Detailed explanation
95
Tor Lillqvist1371d072013-12-18 12:41:34 +020096Note: the below talk about unit tests is obsolete; we no longer have
97any makefilery etc to build unit tests for Android.
98
Tor Lillqvista9d167b2011-11-11 16:44:18 +020099Unit tests are the first thing we want to run on Android, to get some
Miklos Vajna971228a2013-11-23 16:06:47 +0100100idea how well, if at all, the basic LO libraries work. We want to
Tor Lillqvista9d167b2011-11-11 16:44:18 +0200101build even unit tests as normal Android apps, i.e. packaged as .apk
102files, so that they run in a sandboxed environment like that of
103whatever eventual end-user Android apps there will be that use LO
104code.
105
Tor Lillqvist05d0bdb2012-01-03 15:27:41 +0200106Sure, we could quite easily build unit tests as plain Linux
107executables (built against the Android libraries, of course, not
108GNU/Linux ones), push them to the device or emulator with adb and run
109them from adb shell, but that would not be a good test as the
110environment such processs run in is completely different from that in
111which real end-user apps with GUI etc run. We have no intent to
112require LibreOffice code to be used only on "rooted" devices etc.
Tor Lillqvista9d167b2011-11-11 16:44:18 +0200113
114All Android apps are basically Java programs. They run "in" a Dalvik
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +0300115virtual machine. Yes, you can also have apps where all *your* code is
Tor Lillqvista9d167b2011-11-11 16:44:18 +0200116native code, written in a compiled language like C or C++. But also
117also such apps are actually started by system-provided Java
118bootstrapping code (NativeActivity) running in a Dalvik VM.
119
120Such a native app (or actually, "activity") is not built as a
121executable program, but as a shared object. The Java NativeActivity
122bootstrapper loads that shared object with dlopen.
123
Tor Lillqvist30fded62013-03-18 09:24:41 +0200124Anyway, our current "experimental" apps (DocumentLoader,
Viktor Varga9b1e83c2013-08-28 11:19:52 +0200125LibreOffice4Android and LibreOfficeDesktop) are not based on
Tor Lillqvist30fded62013-03-18 09:24:41 +0200126NativeActivity any more. They have normal Java code for the activity,
127and just call out to a single, app-specific native library (called
128liblo-native-code.so) to do all the heavy lifting.