注意将 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 {
}

posted on 2024-02-25 16:24  oLd-Y  阅读(71)  评论(0编辑  收藏  举报