blob: ac11fb98b672ef8feed36802b6f58822705007e6 [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
4reality...
5
6* Getting something running on an emulated device
Michael Meeksa0ce2a22012-01-20 09:44:00 +00007
8 Create an AVD in the android UI, don't even try to get
9the data partition size right in the GUI, that is doomed to producing
10and AVD that doesn't work. Instead start it from the console:
11
Miklos Vajna09189c32012-11-09 15:12:47 +010012 LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500
13
14In order to have proper acceleration, you need the 32-bit libGL.so:
15
16 sudo zypper in Mesa-libGL-devel-32bit
Michael Meeksa0ce2a22012-01-20 09:44:00 +000017
18 Where <Name> is the literal name of the AVD that you entered.
Michael Meeksa0ce2a22012-01-20 09:44:00 +000019
20 Then:
21
Michael Meeks739252d2012-02-27 14:16:54 +000022 make cmd cmd=bash
Michael Meeksa0ce2a22012-01-20 09:44:00 +000023 cd android/qa/sc
24 make clean all install
25 make run ; adb shell logcat
26
Tor Lillqvistb58498f2012-05-17 10:09:22 +030027 And if all goes well - you should have some nice unit test output to
28enjoy. After a while of this loop you might find that you have lost a lot of
29space on your emulator's or device's /data volume. If using the emulator, you
30can do:
Michael Meeks56db0772012-01-20 10:19:42 +000031
Tor Lillqvistb58498f2012-05-17 10:09:22 +030032 adb shell stop; adb shell start
33
34but on a (non-rooted) device you probably just need to reboot it. On the other
35hand, this phenomenon might not happen on actual devices.
Michael Meeks56db0772012-01-20 10:19:42 +000036
37 and continue onwards & upwards.
Michael Meeksa0ce2a22012-01-20 09:44:00 +000038
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030039* What about using a real device?
40
41 That works fine, too. You won't be able to use the "adb shell
42stop" and "adb shell start" commands to do anything, as far as I
43know. But don't seem to be necessary on a real device anyway?
44
Michael Meeks0eef5f62012-01-20 12:08:01 +000045* Debugging
46
47 Debugging is fun, the default NDK gdb (in v7) is busted, you
48need to download a new one from:
49
50 http://code.google.com/p/mingw-and-ndk/
51
52 Even this 'fixed' gdb is broken in the way that it can see
53symbols only for shlibs that were already loaded when the debuggee was
54attached, so you need to carefully guess where to put:
55
56 fprintf(stderr, "Sleeping NOW!\n"); ::sleep(20);
57
58 into the code; and when you see that in logcat, you have time
59to run: ndk-gdb and it will attach the process.
60
Michael Meekse74a3582012-01-23 17:08:55 +000061 thread 12 # or perhaps 13
62 backtrace
63
64 may show you the native code trace.
65
Tor Lillqvist0f9f8ef2012-09-10 14:28:34 +030066 In r8b the ndk-gdb seems to work a bit better, and I think it isn't
67necessary to use the mingw-and-ndk ndb-gdb any longer.
68
69
Michael Meeksdb9ca8e2012-01-20 17:18:35 +000070* Common Errors / Gotchas
71
72lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
73 This (most likely) means that the install quietly failed, and that
74the file is truncated; check it out with adb shell ls -l /data/data/....
75
76
Michael Meeksa0ce2a22012-01-20 09:44:00 +000077* Detailed explanation
78
Tor Lillqvista9d167b2011-11-11 16:44:18 +020079Unit tests are the first thing we want to run on Android, to get some
80idea how well, if at all, the basic LO libraraies work. We want to
81build 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,
105LibreOffice4Android and LibreOfficeDesbktop) are not based on
106NativeActivity 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.