I have an Android project and we have been using the experimental Gradle Plugin for some time. with Android Studio 3 being announced and the move to Gradle 4, I have a couple of questions
In just looking no one has added a new experimental gradle release in a couple of months, and the last version 11 alpha is 3 months ago. Is this still being maintained?
Is there a better way to do complicated NDK builds then the experimental Gradle plugin? I did a little research and it looks like there is a way to have a cMake txt file and call that as they did with this Samba client
https://github.com/google/samba-documents-provider/tree/master/app
When I say complicated NDK build, I have a number of C++ libraries I'm pulling together. I have a bunch of custom c++ code, I have a couple of 3rd party libraries that have their own code as well as shared libraries. And I have a number of jni interface files to manage it all.
I shortened this example, but I have 12 so files.
model {
// this repositories section defines our list of external shared libraries
// included here are all nuance libs and python 3.5
repositories {
libs(PrebuiltLibraries) {
lib1 {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("src/main/jniLibs/${targetPlatform.getName()}/lib1.so")
}
}
lib2{
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("src/main/jniLibs/${targetPlatform.getName()}/lib2.so")
}
}
}
}
I then have the following for an NDK section
// defines the NDK build
ndk {
moduleName "myApp"
toolchain = "clang"
// We set the platform for the NDK. with the a certain device we were getting missing libraries without it
// https://github.com/android-ndk/ndk/issues/126
platformVersion="23"
// If switching to GNU, here are the values to replace with
stl "gnustl_shared"
CFlags.addAll(["-DNDEBUG"])
cppFlags.addAll(["-fexceptions", "-std=gnu++11"])
// when adding system library dependencies, they are added here
ldLibs.addAll(["log","atomic"])
// C include directories
CFlags.addAll(["-I${file("src/main/jni/lib1/inc")}".toString(),
"-I${file("src/main/jni/lib2")}".toString()
])
// C++ include directories
cppFlags.addAll(["-I${file("src/main/jni/lib1/inc")}".toString(),
"-I${file("src/main/jni/lib1")}".toString(),
"-I${file("src/main/jni/lib2")}".toString(),
"-I${file("src/main/jni/lib2/os")}".toString(),
"-I${file("src/main/jni")}".toString()
])
}
`
Then also in the gradle I list all my jni sources
// this section is to list the NDK static/shared library dependencies
// these dependencies are defined in detail above in the repositories section
sources {
main {
jni {
dependencies {
library "lib1"
library "lib2"
library "lib3"
library "lib4"
library "lib5"
library "lib6"
library "lib7"
library "lib8"
library "lib9"
library "lib10"
library "lib11"
library "lib12"
}
}
}
}