2011-11-11 08:44:18 -06:00
|
|
|
Android-specific notes
|
|
|
|
|
2012-09-10 06:28:34 -05:00
|
|
|
Note that this document has not necessarily been updated to match
|
|
|
|
reality...
|
|
|
|
|
|
|
|
* Getting something running on an emulated device
|
2012-01-20 03:44:00 -06:00
|
|
|
|
|
|
|
Create an AVD in the android UI, don't even try to get
|
|
|
|
the data partition size right in the GUI, that is doomed to producing
|
|
|
|
and AVD that doesn't work. Instead start it from the console:
|
|
|
|
|
2012-11-09 08:12:47 -06:00
|
|
|
LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500
|
|
|
|
|
|
|
|
In order to have proper acceleration, you need the 32-bit libGL.so:
|
|
|
|
|
|
|
|
sudo zypper in Mesa-libGL-devel-32bit
|
2012-01-20 03:44:00 -06:00
|
|
|
|
|
|
|
Where <Name> is the literal name of the AVD that you entered.
|
|
|
|
|
|
|
|
Then:
|
|
|
|
|
2012-02-27 08:16:54 -06:00
|
|
|
make cmd cmd=bash
|
2012-01-20 03:44:00 -06:00
|
|
|
cd android/qa/sc
|
|
|
|
make clean all install
|
|
|
|
make run ; adb shell logcat
|
|
|
|
|
2012-05-17 02:09:22 -05:00
|
|
|
And if all goes well - you should have some nice unit test output to
|
|
|
|
enjoy. After a while of this loop you might find that you have lost a lot of
|
|
|
|
space on your emulator's or device's /data volume. If using the emulator, you
|
|
|
|
can do:
|
|
|
|
|
|
|
|
adb shell stop; adb shell start
|
2012-01-20 04:19:42 -06:00
|
|
|
|
2012-05-17 02:09:22 -05:00
|
|
|
but on a (non-rooted) device you probably just need to reboot it. On the other
|
|
|
|
hand, this phenomenon might not happen on actual devices.
|
2012-01-20 04:19:42 -06:00
|
|
|
|
|
|
|
and continue onwards & upwards.
|
2012-01-20 03:44:00 -06:00
|
|
|
|
2012-09-10 06:28:34 -05:00
|
|
|
* What about using a real device?
|
|
|
|
|
|
|
|
That works fine, too. You won't be able to use the "adb shell
|
|
|
|
stop" and "adb shell start" commands to do anything, as far as I
|
|
|
|
know. But don't seem to be necessary on a real device anyway?
|
|
|
|
|
2012-01-20 06:08:01 -06:00
|
|
|
* Debugging
|
|
|
|
|
|
|
|
Debugging is fun, the default NDK gdb (in v7) is busted, you
|
|
|
|
need to download a new one from:
|
|
|
|
|
|
|
|
http://code.google.com/p/mingw-and-ndk/
|
|
|
|
|
|
|
|
Even this 'fixed' gdb is broken in the way that it can see
|
|
|
|
symbols only for shlibs that were already loaded when the debuggee was
|
|
|
|
attached, so you need to carefully guess where to put:
|
|
|
|
|
|
|
|
fprintf(stderr, "Sleeping NOW!\n"); ::sleep(20);
|
|
|
|
|
|
|
|
into the code; and when you see that in logcat, you have time
|
|
|
|
to run: ndk-gdb and it will attach the process.
|
|
|
|
|
2012-01-23 11:08:55 -06:00
|
|
|
thread 12 # or perhaps 13
|
|
|
|
backtrace
|
|
|
|
|
|
|
|
may show you the native code trace.
|
|
|
|
|
2012-09-10 06:28:34 -05:00
|
|
|
In r8b the ndk-gdb seems to work a bit better, and I think it isn't
|
|
|
|
necessary to use the mingw-and-ndk ndb-gdb any longer.
|
|
|
|
|
|
|
|
|
2012-01-20 11:18:35 -06:00
|
|
|
* Common Errors / Gotchas
|
|
|
|
|
|
|
|
lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
|
|
|
|
This (most likely) means that the install quietly failed, and that
|
|
|
|
the file is truncated; check it out with adb shell ls -l /data/data/....
|
|
|
|
|
|
|
|
|
2012-01-20 03:44:00 -06:00
|
|
|
* Detailed explanation
|
|
|
|
|
2011-11-11 08:44:18 -06:00
|
|
|
Unit tests are the first thing we want to run on Android, to get some
|
|
|
|
idea how well, if at all, the basic LO libraraies work. We want to
|
|
|
|
build even unit tests as normal Android apps, i.e. packaged as .apk
|
|
|
|
files, so that they run in a sandboxed environment like that of
|
|
|
|
whatever eventual end-user Android apps there will be that use LO
|
|
|
|
code.
|
|
|
|
|
2012-01-03 07:27:41 -06:00
|
|
|
Sure, we could quite easily build unit tests as plain Linux
|
|
|
|
executables (built against the Android libraries, of course, not
|
|
|
|
GNU/Linux ones), push them to the device or emulator with adb and run
|
|
|
|
them from adb shell, but that would not be a good test as the
|
|
|
|
environment such processs run in is completely different from that in
|
|
|
|
which real end-user apps with GUI etc run. We have no intent to
|
|
|
|
require LibreOffice code to be used only on "rooted" devices etc.
|
2011-11-11 08:44:18 -06:00
|
|
|
|
|
|
|
All Android apps are basically Java programs. They run "in" a Dalvik
|
2012-09-10 06:28:34 -05:00
|
|
|
virtual machine. Yes, you can also have apps where all *your* code is
|
2011-11-11 08:44:18 -06:00
|
|
|
native code, written in a compiled language like C or C++. But also
|
|
|
|
also such apps are actually started by system-provided Java
|
|
|
|
bootstrapping code (NativeActivity) running in a Dalvik VM.
|
|
|
|
|
|
|
|
Such a native app (or actually, "activity") is not built as a
|
|
|
|
executable program, but as a shared object. The Java NativeActivity
|
|
|
|
bootstrapper loads that shared object with dlopen.
|
|
|
|
|
2013-03-18 02:24:41 -05:00
|
|
|
Anyway, our current "experimental" apps (DocumentLoader,
|
2013-08-28 04:19:52 -05:00
|
|
|
LibreOffice4Android and LibreOfficeDesktop) are not based on
|
2013-03-18 02:24:41 -05:00
|
|
|
NativeActivity any more. They have normal Java code for the activity,
|
|
|
|
and just call out to a single, app-specific native library (called
|
|
|
|
liblo-native-code.so) to do all the heavy lifting.
|