Skip to content

Instantly share code, notes, and snippets.

@ethankhall
Last active December 16, 2015 17:29
Show Gist options
  • Save ethankhall/5470680 to your computer and use it in GitHub Desktop.
Save ethankhall/5470680 to your computer and use it in GitHub Desktop.
Using Gradle with the Android plugin to add a JNI project to the APK.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.3'
}
}
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
repositories {
mavenCentral()
}
//apply plugin: 'java'
apply plugin: 'android'
android {
compileSdkVersion 17
defaultConfig {
versionCode = 1
versionName = "0.0"
}
}
task wrapper(type: org.gradle.api.tasks.wrapper.Wrapper) {
gradleVersion = '1.4'
}
dependencies{
compile project(":subProject:jni")
}
include ':subProject:jni'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.3'
}
}
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
//apply plugin: 'java'
apply plugin: 'android-library'
//apply plugin: 'android'
android {
compileSdkVersion 17
defaultConfig {
versionCode = 1
versionName = "0.0"
}
}
repositories {
mavenCentral()
}
dependencies{
}
task wrapper(type: org.gradle.api.tasks.wrapper.Wrapper) {
gradleVersion = '1.4'
}
task copyNativeLibs(type: Copy) {
from fileTree(dir: 'libs', include: '**/*.so' )
into 'build/native-libs'
}
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn 'cleanCopyNativeLibs'
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniDir new File('build/native-libs')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment