Created
October 10, 2013 07:25
-
-
Save dylanPowers/6914381 to your computer and use it in GitHub Desktop.
A sample build.gradle script that incorporates the Android NDK. This differs from a lot of samples out there because it makes use of the new default directory setup.
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.5.+' | |
} | |
} | |
apply plugin: 'android' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'com.android.support:support-v4:13.0.+' | |
} | |
android { | |
compileSdkVersion 16 | |
buildToolsVersion "18.1" | |
defaultConfig { | |
minSdkVersion 16 | |
targetSdkVersion 16 | |
} | |
} | |
// NDK build support | |
task buildNative(type: Exec) { | |
// A lot of samples don't specify the build directory. | |
commandLine 'ndk-build', '-C', 'src/main' | |
} | |
tasks.withType(Compile) { compileTask -> compileTask.dependsOn 'buildNative' } | |
clean.dependsOn 'cleanNative' | |
task cleanNative(type: Exec) { | |
commandLine 'ndk-build', 'clean', '-C', 'src/main' | |
} | |
// Copies the libs to the apk. | |
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> | |
pkgTask.jniDir new File(projectDir, 'src/main/libs') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment