Building for Android
(some more details)
|Line 1:||Line 1:|
The build instructions should differ only minimally between operating systems. It might be possible to build through QtCreator, but I've
The build instructions should differ only minimally between operating systems. It might be possible to build through QtCreator, but I've to
== Prerequisites ==
== Prerequisites ==
Revision as of 03:43, 8 February 2012
The build instructions should differ only minimally between operating systems. It might be possible to build through QtCreator, but I've no idea how to do so (see below)
- Necessitas (the Qt port for Android). The necessitas package includes the Android SDK and NDK, QtCreator, and the Qt libraries
- API 11 is the current target, so you may want to install that (it may be wise for us to target 10 or an earlier one, however); if using another target, be sure to comment out the bits of the necessitas Java code that's aren't applicable (they're prefixed by //@ANDROID-XX; it looks like necessitas QtCreator is supposed to treat these as preprocessor directives)
- JDK 6. Not JRE, not JDK 7
- If you have JRE installed, the JAVA_HOME environment variable may be pointing at that instead of the JDK.
Through your distro's package manager, install:
- cmake (>= 2.8 is required)
Use MacPorts to install Bazaar. In a terminal window:
$ sudo port install bzr
- bazaar (you'll likely want to check TortoiseBzr in the installer)
- MinGW/MSYS (be sure you check "MSYS shell environment" in in the installer)
Sync to experimental Android branch
The code currently resides in a personal branch.
bzr checkout lp:~brady.brenot/stellarium/android-port
I'm using build scripts based on QGIS' Android port from Marco Bernasocchi. These will make sure the build environment is set up correctly, that everything is set up for cross-compiling instead of compiling for your system, that the files all end up in the right places, and that the apk is built from those files. You can do all of this manually, but it's a considerably larger amount of typing than is required to build for the other platforms.
stellarium/android/util directory, copy
config.conf, and edit according to the instructions within.
Open up a terminal, head into the
stellarium/android/util directory, and run
Assuming you configured the config.conf correctly, Stellarium should build without a hitch.
Deploy to device
This is a necessary step to test Stellarium, as the Android emulator lacks OpenGL ES 2 support and will crash very quickly. Get the Android device connected to your computer by USB and make sure the adb drivers are installed (may be automatic, but it varies according to device), or use adbWireless to connect over wifi. Once you've connected and got adb working, run:
to install, then run the apk, or:
To quickly rebuild/install/run it.
Debug with gdb
(I haven't actually tested this yet, but it should work as described below)
Import the project into Eclipse as described below. If you need to debug as soon as the native code starts, set a breakpoint right before the necessitas code starts up the native side of the app.
Now, on the device (or, do it on your workstation by prefixing these commands with "adb shell"):
Find the process ID for Stellarium.
Then attach gdbserver to it
gdbserver :5039 --attach pid
On your workstation, have ADB forward port from the device
adb forward tcp:5039 tcp:5039
Now, I have the feeling that the build process doesn't strip symbols from debug executables (if we'd used ndk-build, it would), so you likely don't have to give gdb an unstripped version of the library. However, the downside is that the library is enormous... then again, it's probably dwarfed by the size of the supporting files, so no biggie.
Open gdb, which should reside somewhere in the android ndk or sdk directories (figure out where).
Tell gdb where your source is
Instructions on using gdb are beyond the scope of this document. You're on your own.
Now you should be able to resume in Eclipse and in gdb, and debug as usual.
Debug with QtCreator
I haven't the foggiest. If anyone wants to investigate this, please go right ahead :)
To import the project into QtCreator
necessitas-qtcreator.sh script. This will start necessitas' QtCreator.
build-stel.sh script, uncommenting the lines to echo the cmake flags and then exit. Run it, saving the cmake flags out to a file (
./build-stel.sh > flags.out). Copy the flags.
In QtCreator, open the CMakeLists.txt in the root of the directory where you've checked out Stellarium. In the following windows, choose "MinGW Makefiles" or "Unix Makefiles" as the generator, paste the flags into the cmake arguments box, and click "Run cmake". Proceed, and you should be done.
However, when you try to run or debug the app, it builds the code and then does nothing with it. Not sure how to resolve that, or how to get it to attach to a process on a device. QtCreator is still a very nice IDE for editing the code, though.
There is some Java code here, but thanks to necessitas it should be kept to a minimum (aside from localization and bits from necessitas itself).
Debug with Eclipse
Install Eclipse (preferably Eclipse Classic). Follow the directions for installing ADT.
Create a new project, choose Android project, and choose "Create project from existing source". Point Eclipse at the
stellarium/android/java directory. Go to Project -> Properties, and set the JDK compliance level to 1.6. You can now use Eclipse to build and debug the software. If debugging, as noted above, you must use a device. Stellarium will not run in the Android emulator.