apply plugin: 'com.android.library' android { compileSdkVersion 23 buildToolsVersion '25.0.0' defaultConfig { minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { jni.srcDirs = [] java.srcDirs = ['src/main/java'] resources.srcDirs = ['src/main/res'] res.srcDirs = ['src/main/res'] jniLibs.srcDirs = ['src/main/libs'] assets.srcDirs = ['src/main/assets'] } } task buildNative(type: Exec, description: 'Compile JNI source via NDK') { def ndkDir = android.ndkDirectory commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source '-j', Runtime.runtime.availableProcessors(), 'all', 'NDK_DEBUG=1' } task cleanNative(type: Exec, description: 'Clean JNI object files') { def ndkDir = android.ndkDirectory commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source 'clean' } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn(buildNative) } clean.dependsOn 'cleanNative' } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' } configurations.maybeCreate("default") artifacts.add("default", file('build/outputs/aar/ccnxsupportlibrary-release.aar'))