Building Android NDK projects with Gradle and Travis CI

I’ve migrated all of my Android projects over to Gradle now as that seems to be the direction that Android development is taking, but if you use the Android NDK in your projects then you’ll discover that NDK support is severely lacking in Gradle. There’s undocumented support for the NDK which can be found if you dive into the samples, but it doesn’t look to be too developed at the moment. Until there’s an official solution for this, I’ve taken my own approach to this, inspired by countless StackOverflow questions and answers.

I also use Gradle in combination with GitHub and Travis CI in order to build and test the latest commits automatically, so I’ll share the .travis.yml build script that I use to do this.

This may not be the best way of doing this, and it will probably be made obsolete when an official solution is documented. However, it works for me. If you know of a better solution then please leave a comment.