美文网首页
android studio 直接编译JNI

android studio 直接编译JNI

作者: 尔乐 | 来源:发表于2016-07-16 20:57 被阅读26次

    tasks.withType(JavaCompile) {

    compileTask -> compileTask.dependsOnndkBuild

    }

    task ndkBuild(type: Exec) {

    workingDir file("jni")

    commandLinegetNdkBuildCmd()

    }

    task cleanNative(type: Exec){

    workingDir file("jni")

    commandLinegetNdkBuildCmd(),"clean"

    }

    clean.dependsOncleanNative

    defgetNdkDir() {

    if(System.env.ANDROID_NDK_ROOT !=null)

    returnSystem.env.ANDROID_NDK_ROOT

    Properties properties =newProperties()

    properties.load(project.rootProject.file("local.properties").newDataInputStream())

    defndkdir = properties.getProperty("ndk.dir",null)

    if(ndkdir ==null)

    throw newGradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")

    returnndkdir

    }

    defgetNdkBuildCmd() {

    defndkbuild =getNdkDir() +"/ndk-build"

    //    ndkbuild+=".cmd" //mac 屏蔽这句

    returnndkbuild

    }

    相关文章

      网友评论

          本文标题:android studio 直接编译JNI

          本文链接:https://www.haomeiwen.com/subject/lwyujttx.html