3.6KB

Title: October 2016 recap Date: 2016-11-19 00:00 Category: News Slug: 2016-october-recap Lang: en

Gaining Android support was like climbing a mountain for us

This article describes how we spent a month building OpenSceneGraph (OSG) for Android: the first attempt to build OSG, the search for OSG alternatives, and the success in building OSG.

First attempt to build OSG.

Having no prior knowledge of Android development, we grabbed the latest Android Studio and started doing beginner tutorials. We passed Java part pretty fast. Everything worked out of the box. Then came C++ part and related problems.

**CMake. **To work with C++, Android Studio uses custom CMake, which conflicts with the system one. This was a clear indication that we had to set up a separate development environment specifically for Android.

**KVM. **We got Ubuntu under VirtualBox installed. All went fine until we tried to use Android Emulator. Turned out, VirtualBox could not run Android Emulator, because a virtual machine cannot provide kernel virtualization inside already virtualized environment.

**Chroot for Android. **Since we had a successful experience with chroot to build OGS Editor before, we decided to place Android development environment into chroot. With minor tweaking, we could finally run Android Emulator and build C++ project.

**OSG. **Building OSG seemed like a piece of cake at the time. However, all we got was a crash. Thinking that we got it wrong the first time, we tried to rebuild OSG once again. And the same crash again. Searching for the problem did not reveal any hint. Nobody helped us at the OSG mailing list.

We were in despair.

The search for OSG alternatives.

Since OSG community did not help us, we decided to search for an alternative open source project to fit our Android needs (and may be more).

And we found it: BabylonHX. The home page looked awesome: it rendered WebGL in the background! We thought we finally found the gem we were looking for. However, the example on the home page simply did not work.

You can probably understand our feelings at the time.

The success in building OSG.

We realized nobody would make OSG work under Android for us. We had to do it ourselves.

Since OSG 3.4 document on building for Android was very short, we no longer trusted it and headed to original OSG 3.0 document. While following it, we faced a dead link to third party dependencies. The search for an alternative download link lead us to a 2013 tutorial on building OSG 3.0 for Android.

After following the tutorial, we finally got OSG to run under Android! But there was a nuance: both OSG and Android tools used in the tutorial were ancient. In a few days, we gradually updated both OSG and Android tools to their latest versions.

During the update process, we learned two things that prevented us from having OSG to work in the first place:

  • Android API headers changed in NDK r12
  • OSG only works as a static library under Android

That's it for describing how we spent the month building OSG for Android: the first attempt to build OSG, the search for OSG alternatives, and the success in building OSG.