注意将 openCVersionName
, openCVersionCode
, compileSdk
, minSdk
进行相应的修改即可.
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
val openCVersionName = "4.9.0"
val openCVersionCode = ((4 * 100 + 9) * 100 + 0) * 10 + 0
println("OpenCV: " + openCVersionName + " " + project.buildscript.sourceFile)
android {
namespace = "org.opencv"
compileSdk = 34
defaultConfig {
minSdk = 24
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments("-DANDROID_STL=c++_shared")
targets("opencv_jni_shared")
}
}
}
buildTypes {
debug {
packaging {
jniLibs{
keepDebugSymbols.add("**/*.so")
}
}
}
release {
packaging {
jniLibs{
keepDebugSymbols.add("**/*.so")
}
}
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro"
)
}
}
sourceSets {
getByName("main") {
jniLibs.srcDirs("native/libs")
java.srcDirs("java/src")
aidl.srcDirs("java/src")
res.srcDirs("java/res")
manifest.srcFile("java/AndroidManifest.xml")
}
}
externalNativeBuild {
cmake {
path = file("${project.projectDir}/libcxx_helper/CMakeLists.txt")
}
}
}
dependencies {
}
标签:java,示例,srcDirs,gradle,opencv,build,android
From: https://www.cnblogs.com/oLd-Y/p/18032565