Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gradle build files for Android native library development
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: '*.jar')
}
task packageNativeLibs_ARM(type: Jar) {
baseName 'libtestlib'
classifier 'armeabi'
from(file('libs/armeabi/')) {
include '**/*.so'
}
into('lib/armeabi')
destinationDir(file('libs/'))
}
task packageNativeLibs_x86(type: Jar) {
baseName 'libtestlib'
classifier 'x86'
from(file('libs/x86/')) {
include '**/*.so'
}
into('lib/x86')
destinationDir(file('libs/'))
}
task packageNativeLibs(description: "package native libraries") {
}
packageNativeLibs.dependsOn 'packageNativeLibs_ARM'
packageNativeLibs.dependsOn 'packageNativeLibs_x86'
task ndkBuild(type: Exec, description: "Task to run ndk-build") {
commandLine ndkDir + '/ndk-build'
}
packageNativeLibs.dependsOn 'ndkBuild'
tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn packageNativeLibs }
clean.dependsOn 'cleanPackageNativeLibs'
# properties file
# set your NDK code path here:
ndkDir=/Users/user/android-ndk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.