Android experimental gradle plugin & Android Studio 3

672 Views Asked by At

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

  1. 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?

  2. 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"
                }
            }
    }
}
1

There are 1 best solutions below

0
On BEST ANSWER

So to answer my own questions above.

  1. It's been announced that the experimental gradle plugin will no longer be supported after 0.11.0. So no it's no longer maintained.

  2. My project was converted over to use CMake. With the latest gradle 4.1 and converting everything to CMake and the CMakeLists.txt type of build we were able to get the project to build without the experimental version of gradle.