简体   繁体   English

Android实验性Gradle插件和Android Studio 3

[英]Android experimental gradle plugin & Android Studio 3

I have an Android project and we have been using the experimental Gradle Plugin for some time. 我有一个Android项目,并且一段时间以来我们一直在使用实验性Gradle插件。 with Android Studio 3 being announced and the move to Gradle 4, I have a couple of questions 随着Android Studio 3的发布和Gradle 4的发布,我有几个问题

  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. 仅仅几个月,没有人添加新的实验性Gradle版本,而最新的11 alpha版本是3个月前。 Is this still being maintained? 这仍然保持吗?

  2. Is there a better way to do complicated NDK builds then the experimental Gradle plugin? 有没有比实验性Gradle插件更好的方法来进行复杂的NDK构建? 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 我做了一些研究,看来有一种方法可以像使用此Samba客户端一样来获取cMake txt文件并调用该文件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. 当我说复杂的NDK构建时,我会收集许多C ++库。 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. 我有一堆自定义的c ++代码,我有几个第三方库,它们都有自己的代码以及共享库。 And I have a number of jni interface files to manage it all. 我有许多jni接口文件来管理所有这些。

I shortened this example, but I have 12 so files. 我简化了这个示例,但是我有12个so文件。

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 然后,我在NDK部分有以下内容

// 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 然后也在gradle中列出我所有的jni来源

   // 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"
                }
            }
    }
}

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. 宣布0.11.0之后将不再支持实验性gradle插件。 So no it's no longer maintained. 所以不,它不再被维护。

  2. My project was converted over to use CMake. 我的项目已转换为使用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. 使用最新的gradle 4.1并将所有内容转换为CMake和CMakeLists.txt类型的构建,我们能够在没有实验版gradle的情况下构建项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM