Add Android gradle build script with NDK cmake and prefab packaging (+ on device test script)
Added an android subdirectory for building a prefab package and .aar with the Android NDK and gradle build system.
The build script supports building a ready-to-use android library (.aar) via:
cd android/ && gradle assembleRelease
Tests may be run on a connected device or emulator via:
cd android/ && gradle ndkTest
See the updated documentation in Building-for-Android.md for details.
Cool, hey thanks.
I have limited experience with Gradle, very little with Android dev, so I don't think I can review this. @SoapGentoo @evpobr ?
Would you, @jg-hot , feel confident maintaining this build system?
@arthurt Absolutely. I do feel comfortable with this build given that the tests are running and passing on:
-
x86_64emulator -
arm64-v8aphysical device - Emulator running
API 35with 16KB page sizes: there was a recent change in the NDK which required all NDK code to be rebuilt with new flags. This is already supported and passing forlibsndfile.
If it would be helpful, I can provide the test output (I know not everyone has access to the environment / devices to run the tests). I would also be fine merging changes from this branch into my fork, running the tests, and updating anything if necessary (although breaking changes should be unlikely).
I will probably migrate this build to eliminate the gradle dependency following the pattern that Oboe uses, at some point. You would still need the NDK installed (to build), prefab and mvn (to publish), and adb and a device or emulator to test.
I also have an open PR for an Android build for libsamplerate and I'm working on libmp3lame and a few other libraries as well.
I added support for ENABLE_EXTERNAL_LIBS and ENABLE_MPEG, and this build now links to libogg, libvorbis, libopus, libflac, libmpg123, and libmp3lame.
I've published stable prefab releases of all these libraries to Github packages.
You can now simply add the dependencies and use them without building anything, similar to how oboe works:
-
libsndfile-android v1.2.2-r1[package] [source] -
libogg-android v1.3.5-r1[package] [source] -
libvorbis-android v1.3.7-r1[package] [source] -
libopus-android v1.5.2-r1[package] [source] -
libflac-android v1.4.3-r1[package] [source] -
libmpg123-android v1.32.9-r1[package] [source] -
libmp3lame-android v3.100-r1[package] [source]
Below is the output of ndk-test.sh showing passing tests on a physical Samsung device with arm64-v8a and armeabi-v7a ABIs.
https://gist.github.com/jg-hot/25caea21b0dd1c40719a50121df1dcd8
The tests are also passing on x86 and x86_64 emulators, including those with 16KB page sizes.
There are a few things I'd still like to clean up in this PR:
- Update build file to allow specifying whether or not to include Xiph / MPEG libs. This would be trivial, but in this case, the prefab .json files need to be updated based on the configuration
- Publish libraries to maven central instead of github packages to make it easier for consumers to include them, without specifying additional repositories
- Update Android documentation
But for anyone who wants to use this build today, it's basically ready to go! If you need help using it, feel free to leave a comment here until I have a chance to update the docs.