如何导入android实验模块

时间:2016-01-06 12:17:59

标签: android gradle-experimental

我有实验(v:0.4.0)的android模块,它使用带有模块的gradle文件,如下所示:

apply plugin: 'com.android.mode.application'

model {
android {
    compileSdkVersion = 21
    buildToolsVersion = "21.1.2"

    defaultConfig.with {
        applicationId = "com.example.native_libs"
        minSdkVersion.apiLevel = 10
        targetSdkVersion.apiLevel = 21
    }
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:21.0.3'
    }
}

compileOptions.with {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7
}

/*
 * native build settings
 */
android.ndk {
    moduleName = "native_libs"
    stl = "stlport_static"
    cppFlags.add("-fexceptions")
    cppFlags.add("-fno-rtti")
    cppFlags.add("-std=gnu++11")
    ldLibs.add("z")
    /*
     * Other ndk flags configurable here are
     * cppFlags.add("-fno-rtti")
     * cppFlags.add("-fno-exceptions")
     * ldLibs.addAll(["android", "log"])
     * stl       = "system"
     */
}
android.buildTypes {
    debug {
        ndk.with {
            debuggable = true
        }
    }
    release {
        minifyEnabled = false
        proguardFiles.add(file('proguard-rules.txt'))
    }
}

android.productFlavors {
    // for detailed abiFilter descriptions, refer to "Supported ABIs" @
    // https://developer.android.com/ndk/guides/abis.html#sa
    create("arm") {
        ndk.abiFilters.add("armeabi")
    }
    create("arm7") {
        ndk.abiFilters.add("armeabi-v7a")
    }
    create("arm8") {
        ndk.abiFilters.add("arm64-v8a")
    }
    create("x86") {
        ndk.abiFilters.add("x86")
    }
    create("x86-64") {
        ndk.abiFilters.add("x86_64")
    }
    create("mips") {
        ndk.abiFilters.add("mips")
    }
    create("mips-64") {
        ndk.abiFilters.add("mips64")
    }
    // To include all cpu architectures, leaves abiFilters empty
    create("all")
}}

现在和另一个模块一样,我们不能在这个使用实验性插件的模块中导入java包装类。

我将apply plugin: 'com.android.mode.application'更改为apply plugin: 'com.android.mode.library'但没有任何更改,仍然无法识别native_libs模块中的java包装类:(

如何为本机模块库配置gradle? 为什么实验插件不允许导入模块,就像其他模块的正常方式一样?

[编辑]

我读过这个文档 http://tools.android.com/tech-docs/new-build-system/gradle-experimental 但是没有办法导入组合本机(c / c ++)和java的模块。

1 个答案:

答案 0 :(得分:0)

我在github找到了一个完成我想做的事情:)

https://github.com/frogermcs/FlatBuffs