Stellarium android
Stellarium android
Stellarium android
Contents
1 Prerequisites
1.1 All
1.2 Linux
1.3 OS X
1.4 Windows
2 Sync to experimental Android branch
3 Build
3.1 Configure
3.2 Build and deploy
4 Want to contribute, or having problems building?
5 Troubleshooting Stellarium
6 Debug (C++)
6.1 Debug with gdb
6.2 Debug with QtCreator
6.2.1 To import the project into QtCreator
6.2.2 Debugging
7 Debug (Java)
7.1 Debug with Eclipse
Prerequisites
All
1. Necessitas (https://sourceforge.net/p/necessitas/home/necessitas/) (the Qt port for Android). The necessitas package includes the
Android SDK and NDK, QtCreator, and the Qt libraries
API 8 is the current target, so be sure it's installed (the installer checks it be default); this is the lowest API level that support Open GL
ES 2
2. JDK 6 (http://www.oracle.com/technetwork/java/javase/downloads/index.html) . Not JRE, not JDK 7
If you have JRE installed, the JAVA_HOME environment variable may be pointing at that instead of the JDK; you need this to point
to the JDK root directory for ant to work properly
Linux
Through your distro's package manager, install:
1. cmake (>= 2.8 is required)
2. bazaar
OS X
1. cmake (http://www.cmake.org/cmake/resources/software.html)
2. MacPorts (http://www.macports.org/)
Use MacPorts to install Bazaar. In a terminal window:
Windows
1. cmake (http://www.cmake.org/cmake/resources/software.html)
2. bazaar (https://launchpad.net/bzr/+download) (you'll likely want to check TortoiseBzr in the installer)
3. MinGW/MSYS (https://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/) (be sure you check "MSYS shell environment" in in
the installer)
converted by Web2PDFConvert.com
Sync to experimental Android branch
The code currently resides in a personal branch.
More instructions for using Bazaar and Launchpad can be found in the Bazaar and Launchpad documentation.
Build
Configure
Create a subdirectory builds inside the directory where you synced to, and another subdirectory android inside that, so that you've got
stellarium/builds/android/
inside the builds/android directory, you'll want to run cmake, passing in the path to the Android toolchain so that it sets up for cross-compiling
instead of compiling Stellarium for your own system. You also need to export an environment variable for the location of the NDK. The following
commands will do that (replace the path in the export with the path of the ndk on your system):
export ANDROID_NDK=/path/to/necessitas/android-ndk
cmake -DCMAKE_TOOLCHAIN_FILE=../../android/android.toolchain.cmake ../..
But cmake will fail. The error message may mention something that's not in your PATH. Follow the onscreen instructions. To add to your path
(temporarily; doing it permanently varies according to the OS), use the following command in the terminal window:
export PATH=/path/to/some/directory:$PATH
Otherwise, the problem is that you need to configure cmake properly; the default values are for paths on my own system, you'll need to configure
them. To configure cmake, either run
ccmake
in place of cmake in the above command, or edit the CMakeCache.txt file directly in any text editor. The most important Android-specific
parameters are (some will be set by default unless you first built in that directory without the toolchain):
OPENGL_MODE
Set to ES2 for Android devices
BUILD_STATIC_PLUGINS
Currently should be set to 0 as not all plugins support OpenGL ES2
GUI_MODE
Mobile
You can also use Desktop to use the Desktop UI, if you so choose. The Mobile GUI is a work in progress.
NECESSITAS_QT_ROOT
Set this to the path to necessitas' Qt libraries; on Windows, this is normally necessitas/Android/Qt/480
ANDROID_ABI
"armeabi-v7a", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", or "armeabi"
armeabi is the slowest and most compatible (ARMv5 and greater)
armeabi-v7a is faster, and will work on most devices released in the past few years, and maybe all devices that are even
capable of running Stellarium (ARMv7 and greater)
"armeabi-v7a with VFPV3" enables VFPV3-D16 support, which should be compatible with every ARMv7a device. We may
want to test this to see if that's true and whether there's a performance benefit
"armeabi-v7a with NEON" enables NEON and VFPV3 instructions. NEON is a SIMD instruction set that must be specifically
programmed for (there is a compiler option to auto-vectorize code to work with NEON, but that would completely rule out
compatibility with devices that don't have NEON, and may have negligible benefit [1]
(http://wiki.debian.org/ArmHardFloatPort/VfpComparison#NEON) )
I'm thinking the best idea will be compile "armeabi" and "armeabi-v7 with VFPV3", as this should allow pretty good compatibility.
NDK allows libraries for different EABIs to coexist in the same package, and will choose the appropriate one for the device.
ANDROID_NATIVE_API_LEVEL
leave it at default (android-8); this is the lowest API we can use, so using this allows the greatest compatibility. Because we're using
Qt, it's unlikely we'll need the extra features the higher levels give us
converted by Web2PDFConvert.com
make install
make build_apk_debug_no_assets
make deploy_debug_apk
And to run it, either hit the icon (it's currently a Q without a label; this is owing to lazyness, the fix isn't difficult), or run
make run_apk
Troubleshooting Stellarium
If something goes wrong: The log file will be present at /data/data/org.stellarium.stellarium/files/.stellarium/log.txt (you can't view
this on most devices without root) or possibly at /sdcard/stellarium/log.txt (will eventually change it so it always ends up here to avoid the
root requirement). This will hopefully have information on what happened.
If it crashed before creating the log, or if the log doesn't contain anything useful, try running logcat through adb on your PC while you run the app
on the device:
adb logcat
Debug (C++)
Debug with gdb
(Note: there's now an ndk-debug.sh script in stellarium/android/util which handles most of this; I'll have to remember to rewrite this section)
If you need to debug as soon as the native code starts, import the project into Eclipse as described below, and set a breakpoint right before the
necessitas code starts up the native side of the app. This line in QtActivity.java should do the trick:
QtApplication.setQtActivityDelegate(qtLoader);
Pull the app process off the device; this process starts and runs Android apps, so it's the process you're going to be debugging. gdb needs this.
Windows Note: MinGW will interpret the paths in the pull commands below as Windows paths and passes them to adb accordingly
(/system/bin/app_process becomes C:\system\bin\app_process). They're supposed to be paths on the Android device though, not your
converted by Web2PDFConvert.com
system. Either use cmd, or type the paths as //system/bin/app_process
Open gdb, which should reside somewhere in the android ndk directory (in Windows, it's under necessitas/android-ndk-
r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin)
directory path/to/source
Give gdb the executable that it's going to be debugging, the app_process binary you downloaded from the device:
file path/to/app_process
And give it the locations of libstellarium.so, libc.so, and any other libraries so it can find them (you can run the command multiple times, it will
add each directory to the search path):
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.
It should be possible to hook gdb into Eclipse or QtCreator to allow GUI debugging. May want to investigate that at some point. It'll probably be
handy to have a script do most of the setup for this use.
These instructions may be somwhat outdated, especially as they pertain to Windows, as some issues with QtCreator have been fixed in the
beta version of Necessitas. Update pending.
If you don't have the environment variables saved on your account, start necessitas' QtCreator in a terminal window that does. On Windows, you
must start QtCreator for a MinGW shell, otherwise it won't detect the MinGW cmake generator and you'll be quite stuck.
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, put in any cmake commands you need (the toolchain one from above may be all), and run it. If it
fails, look in the directory it's created and edit the CMakeCache.txt as described above.
(I can't get the MinGW Generator to work on Windows, even though it's the only option QtCreator gives. Passing in -G"Unix Makefiles"
appears to work)
To get it to build, deploy, and run the code, you can just add build commands to the project as described above (make install, ...)
Debugging
To have it actually debug the code is not straight-forward. You need to 'trick' Necessitas' QtCreator into working for you, and even then it
probably won't work well:
create an empty Android project
clear out all of the build steps, but leave the deploy/running/debugging steps
copy in the binaries you built using the project you imported above, or symlink to the build directory or something
run it (using an actual device or and Android-15 target)
Debug (Java)
There is some Java code here, but thanks to necessitas it should be kept to a minimum.
converted by Web2PDFConvert.com
Install Eclipse (preferably Eclipse Classic). Follow the directions (http://developer.android.com/sdk/eclipse-adt.html) 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.
Retrieved from "http://www.stellarium.org/wiki/index.php?title=Building_for_Android&oldid=13067"
converted by Web2PDFConvert.com