Skip to content

Instantly share code, notes, and snippets.

@navinpai
Created September 23, 2016 21:54

Revisions

  1. navinpai created this gist Sep 23, 2016.
    15 changes: 15 additions & 0 deletions build.gradle
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    sourceSets.main {
    jni.srcDirs = [] //disable automatic ndk-build call
    jniLibs.srcDir 'src/main/jni'
    }

    task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
    commandLine "<path to your ndk>/ndk-build",
    'NDK_PROJECT_PATH=build/intermediates/ndk',
    'NDK_LIBS_OUT=src/main/jniLibs',
    'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
    'NDK_APPLICATION_MK=src/main/jni/Application.mk'
    }
    tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn ndkBuild
    }