Created
June 12, 2016 01:24
-
-
Save truedat101/c45ff2b69e91d5c8e9c7962d4b96e841 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import org.apache.tools.ant.taskdefs.condition.Os | |
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 21 | |
buildToolsVersion "21.1.2" | |
defaultConfig { | |
applicationId "com.example.hellojni" | |
minSdkVersion 3 | |
targetSdkVersion 3 | |
versionCode 101 | |
versionName "1.0.1" | |
/* | |
ndk { | |
moduleName "hello-jni" | |
} | |
*/ | |
// | |
// NDK Settings | |
// VVVVVVVVVVVV | |
sourceSets.main { | |
jniLibs.srcDir 'src/main/libs' | |
jni.srcDirs = [] //disable automatic ndk-build call | |
} | |
splits { | |
abi { | |
enable true | |
reset() | |
include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' //select ABIs to build APKs for | |
universalApk true //generate an additional APK that contains all the ABIs | |
} | |
} | |
project.ext.versionCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':5, 'mips64':6, 'x86':8, 'x86_64':9] //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-* | |
android.applicationVariants.all { variant -> | |
// assign different version code for each output | |
variant.outputs.each { output -> | |
output.versionCodeOverride = | |
project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + defaultConfig.versionCode | |
} | |
} | |
// call regular ndk-build(.cmd) script from app directory | |
task ndkBuild(type: Exec) { | |
if (Os.isFamily(Os.FAMILY_WINDOWS)) { | |
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath | |
} else { | |
commandLine 'ndk-build', '-C', file('src/main').absolutePath | |
} | |
} | |
tasks.withType(JavaCompile) { | |
compileTask -> compileTask.dependsOn ndkBuild | |
} | |
// ^^^^^^^^^^^^ | |
// NDK Settings | |
// | |
testApplicationId "com.example.hellojni.tests" | |
testInstrumentationRunner "android.test.InstrumentationTestRunner" | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment