| Tor Lillqvist | a9d167b | 2011-11-11 16:44:18 +0200 | [diff] [blame] | 1 | Android-specific notes |
| 2 | |
| Tor Lillqvist | 0f9f8ef | 2012-09-10 14:28:34 +0300 | [diff] [blame] | 3 | Note that this document has not necessarily been updated to match |
| Tor Lillqvist | 2462aa6 | 2014-02-21 22:37:47 +0200 | [diff] [blame] | 4 | reality... |
| 5 | |
| 6 | For instructions on how to build for Android, see README.cross. |
| Tor Lillqvist | 0f9f8ef | 2012-09-10 14:28:34 +0300 | [diff] [blame] | 7 | |
| 8 | * Getting something running on an emulated device |
| Michael Meeks | a0ce2a2 | 2012-01-20 09:44:00 +0000 | [diff] [blame] | 9 | |
| 10 | Create an AVD in the android UI, don't even try to get |
| 11 | the data partition size right in the GUI, that is doomed to producing |
| xjcl | 04a65e2 | 2014-08-04 21:33:49 +0200 | [diff] [blame] | 12 | an AVD that doesn't work. Instead start it from the console: |
| Michael Meeks | a0ce2a2 | 2012-01-20 09:44:00 +0000 | [diff] [blame] | 13 | |
| Miklos Vajna | 09189c3 | 2012-11-09 15:12:47 +0100 | [diff] [blame] | 14 | LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500 |
| 15 | |
| 16 | In order to have proper acceleration, you need the 32-bit libGL.so: |
| 17 | |
| 18 | sudo zypper in Mesa-libGL-devel-32bit |
| Michael Meeks | a0ce2a2 | 2012-01-20 09:44:00 +0000 | [diff] [blame] | 19 | |
| 20 | Where <Name> is the literal name of the AVD that you entered. |
| Michael Meeks | a0ce2a2 | 2012-01-20 09:44:00 +0000 | [diff] [blame] | 21 | |
| 22 | Then: |
| 23 | |
| Michael Meeks | 739252d | 2012-02-27 14:16:54 +0000 | [diff] [blame] | 24 | make cmd cmd=bash |
| Michael Meeks | a0ce2a2 | 2012-01-20 09:44:00 +0000 | [diff] [blame] | 25 | cd android/qa/sc |
| 26 | make clean all install |
| 27 | make run ; adb shell logcat |
| 28 | |
| Tor Lillqvist | b58498f | 2012-05-17 10:09:22 +0300 | [diff] [blame] | 29 | And if all goes well - you should have some nice unit test output to |
| 30 | enjoy. After a while of this loop you might find that you have lost a lot of |
| 31 | space on your emulator's or device's /data volume. If using the emulator, you |
| 32 | can do: |
| Michael Meeks | 56db077 | 2012-01-20 10:19:42 +0000 | [diff] [blame] | 33 | |
| Tor Lillqvist | b58498f | 2012-05-17 10:09:22 +0300 | [diff] [blame] | 34 | adb shell stop; adb shell start |
| 35 | |
| 36 | but on a (non-rooted) device you probably just need to reboot it. On the other |
| 37 | hand, this phenomenon might not happen on actual devices. |
| Michael Meeks | 56db077 | 2012-01-20 10:19:42 +0000 | [diff] [blame] | 38 | |
| 39 | and continue onwards & upwards. |
| Michael Meeks | a0ce2a2 | 2012-01-20 09:44:00 +0000 | [diff] [blame] | 40 | |
| Tor Lillqvist | 0f9f8ef | 2012-09-10 14:28:34 +0300 | [diff] [blame] | 41 | * What about using a real device? |
| 42 | |
| 43 | That works fine, too. You won't be able to use the "adb shell |
| 44 | stop" and "adb shell start" commands to do anything, as far as I |
| 45 | know. But don't seem to be necessary on a real device anyway? |
| 46 | |
| Michael Meeks | 0eef5f6 | 2012-01-20 12:08:01 +0000 | [diff] [blame] | 47 | * Debugging |
| 48 | |
| Jan Holesovsky | c862be0 | 2014-10-13 16:51:08 +0200 | [diff] [blame] | 49 | 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 Lillqvist | 1371d07 | 2013-12-18 12:41:34 +0200 | [diff] [blame] | 54 | Some versions of the NDK had a broken gdb in the way that it can see |
| Michael Meeks | 0eef5f6 | 2012-01-20 12:08:01 +0000 | [diff] [blame] | 55 | symbols only for shlibs that were already loaded when the debuggee was |
| 56 | attached, 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 |
| 61 | to run: ndk-gdb and it will attach the process. |
| 62 | |
| Michael Meeks | e74a358 | 2012-01-23 17:08:55 +0000 | [diff] [blame] | 63 | thread 12 # or perhaps 13 |
| 64 | backtrace |
| 65 | |
| 66 | may show you the native code trace. |
| 67 | |
| Tor Lillqvist | 0f9f8ef | 2012-09-10 14:28:34 +0300 | [diff] [blame] | 68 | In r8b the ndk-gdb seems to work a bit better, and I think it isn't |
| 69 | necessary to use the mingw-and-ndk ndb-gdb any longer. |
| 70 | |
| Jan Holesovsky | d641b54 | 2014-07-14 16:54:11 +0200 | [diff] [blame] | 71 | * Getting the symbols |
| 72 | |
| 73 | In order to be able to debug, you also need the symbols. Currently they are |
| 74 | stripped using a $(STRIP) call in android/Bootstrap/Makefile.shared ; make |
| 75 | sure you change it only to 'cp'. |
| 76 | |
| 77 | But then you need to limit the size of the resulting binary by other means, |
| 78 | that is strip most of the symbols (but the interesting ones) already during |
| 79 | the build. For that, use something like |
| 80 | |
| 81 | --enable-dbgutil |
| 82 | --enable-selective-debuginfo="sal/" |
| 83 | |
| 84 | in your autogen.input (but of course limit the --enable-selective-debuginfo |
| 85 | only to directories / libraries that are interesting to you). |
| Tor Lillqvist | 0f9f8ef | 2012-09-10 14:28:34 +0300 | [diff] [blame] | 86 | |
| Michael Meeks | db9ca8e | 2012-01-20 17:18:35 +0000 | [diff] [blame] | 87 | * Common Errors / Gotchas |
| 88 | |
| 89 | lo_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 |
| 91 | the file is truncated; check it out with adb shell ls -l /data/data/.... |
| 92 | |
| 93 | |
| Michael Meeks | a0ce2a2 | 2012-01-20 09:44:00 +0000 | [diff] [blame] | 94 | * Detailed explanation |
| 95 | |
| Tor Lillqvist | 1371d07 | 2013-12-18 12:41:34 +0200 | [diff] [blame] | 96 | Note: the below talk about unit tests is obsolete; we no longer have |
| 97 | any makefilery etc to build unit tests for Android. |
| 98 | |
| Tor Lillqvist | a9d167b | 2011-11-11 16:44:18 +0200 | [diff] [blame] | 99 | Unit tests are the first thing we want to run on Android, to get some |
| Miklos Vajna | 971228a | 2013-11-23 16:06:47 +0100 | [diff] [blame] | 100 | idea how well, if at all, the basic LO libraries work. We want to |
| Tor Lillqvist | a9d167b | 2011-11-11 16:44:18 +0200 | [diff] [blame] | 101 | build even unit tests as normal Android apps, i.e. packaged as .apk |
| 102 | files, so that they run in a sandboxed environment like that of |
| 103 | whatever eventual end-user Android apps there will be that use LO |
| 104 | code. |
| 105 | |
| Tor Lillqvist | 05d0bdb | 2012-01-03 15:27:41 +0200 | [diff] [blame] | 106 | Sure, we could quite easily build unit tests as plain Linux |
| 107 | executables (built against the Android libraries, of course, not |
| 108 | GNU/Linux ones), push them to the device or emulator with adb and run |
| 109 | them from adb shell, but that would not be a good test as the |
| 110 | environment such processs run in is completely different from that in |
| 111 | which real end-user apps with GUI etc run. We have no intent to |
| 112 | require LibreOffice code to be used only on "rooted" devices etc. |
| Tor Lillqvist | a9d167b | 2011-11-11 16:44:18 +0200 | [diff] [blame] | 113 | |
| 114 | All Android apps are basically Java programs. They run "in" a Dalvik |
| Tor Lillqvist | 0f9f8ef | 2012-09-10 14:28:34 +0300 | [diff] [blame] | 115 | virtual machine. Yes, you can also have apps where all *your* code is |
| Tor Lillqvist | a9d167b | 2011-11-11 16:44:18 +0200 | [diff] [blame] | 116 | native code, written in a compiled language like C or C++. But also |
| 117 | also such apps are actually started by system-provided Java |
| 118 | bootstrapping code (NativeActivity) running in a Dalvik VM. |
| 119 | |
| 120 | Such a native app (or actually, "activity") is not built as a |
| 121 | executable program, but as a shared object. The Java NativeActivity |
| 122 | bootstrapper loads that shared object with dlopen. |
| 123 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 124 | Anyway, our current "experimental" apps (DocumentLoader, |
| Viktor Varga | 9b1e83c | 2013-08-28 11:19:52 +0200 | [diff] [blame] | 125 | LibreOffice4Android and LibreOfficeDesktop) are not based on |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 126 | NativeActivity any more. They have normal Java code for the activity, |
| 127 | and just call out to a single, app-specific native library (called |
| 128 | liblo-native-code.so) to do all the heavy lifting. |