apply plugin: 'com.android.library' android { compileSdkVersion 19 buildToolsVersion '21.1.2' defaultConfig { minSdkVersion 14 targetSdkVersion 19 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } //// This prevents the auto generation of Android.mk sourceSets.main.jni.srcDirs = [] task buildNative(type: Exec, description: 'Compile JNI source via NDK') { def ndkDir = android.plugin.ndkFolder commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath, '-j', Runtime.runtime.availableProcessors(), 'all', 'NDK_DEBUG=1' } task cleanNative(type: Exec, description: 'Clean JNI object files') { def ndkDir = android.plugin.ndkFolder commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath, 'clean' } clean.dependsOn 'cleanNative' tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn buildNative } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } productFlavors { } } dependencies { }