Skip to content

Instantly share code, notes, and snippets.

@Luca96
Last active February 26, 2019 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luca96/32a66ddb8beb78712606cb375ebd4e9d to your computer and use it in GitHub Desktop.
Save Luca96/32a66ddb8beb78712606cb375ebd4e9d to your computer and use it in GitHub Desktop.
build.gradle for Dlib and OpenCV integration with Android
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' // optional
apply plugin: 'kotlin-android-extensions' // optional
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.your.application"
minSdkVersion 16 // remember: at least 16!
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// specify the platform you want to build for
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
externalNativeBuild {
// set c++ flags, specify the STL: c++_shared, gnustl...
cmake {
cFlags "-O3"
cppFlags "-std=c++11 -frtti -fexceptions"
arguments "-DANDROID_PLATFORM=android-16", // remember: same min sdk as before
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_STL=c++_shared",
"-DANDROID_CPP_FEATURES=rtti exceptions"
}
}
}
sourceSets {
// tell to CMake where to find the native pre-build libraries:
main {
jniLibs.srcDirs = [
"src/main/cppLibs/dlib/lib", // remove if you only need opencv
"src/main/cppLibs/opencv" // remove if you only need dlib
]
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
packagingOptions {
pickFirst "**/libc++_shared.so"
}
}
dependencies {
/** your dependencies */
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // optional
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment