Created
November 12, 2013 17:21
-
-
Save maxme/7434896 to your computer and use it in GitHub Desktop.
A gradle build file for Android NDK - uses a trick to put *so files in a jar and add that jar as a project dependency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.6.+' | |
} | |
} | |
apply plugin: 'android' | |
task nativeLibsToJar( | |
type: Zip, | |
description: 'create a jar archive of the native libs') { | |
destinationDir file('./libs') | |
baseName 'native-libs' | |
extension 'jar' | |
from 'libs/' | |
include '**/*.so' | |
into 'lib/' | |
} | |
tasks.withType(Compile) { | |
compileTask -> compileTask.dependsOn(nativeLibsToJar) | |
} | |
clean.dependsOn 'cleanNativeLibsToJar' | |
repositories { | |
mavenCentral() | |
} | |
android { | |
compileSdkVersion 19 | |
buildToolsVersion "19.0.0" | |
defaultConfig { | |
minSdkVersion 7 | |
targetSdkVersion 19 | |
} | |
task ndkBuild(type:Exec) { | |
commandLine 'ndk-build' | |
} | |
tasks.withType(Compile) { | |
compileTask -> compileTask.dependsOn ndkBuild | |
} | |
} | |
dependencies { | |
compile 'com.android.support:appcompat-v7:+' | |
compile files('libs/native-libs.jar') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
small note, now the keyword
Compile
attasks.withType(Compile)
is deprecated, you need to useJavaCompile
like thistasks.withType(JavaCompile)