当前位置: 首页 > news >正文

Kotlin DSL C++项目引入OpenCV异常处理

现象

kotlin DSL(build.rgadle.kts)项目引入openCV sdk 编译提示Plugin [id: 'com.android.application', version: '8.2.1'...错误

Plugin [id: 'com.android.application', version: '8.2.1', apply: false] was not found in any of the following sources:* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.application', version: '8.2.1', apply: false] was not found in any of the following sources:- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.2.1')Searched in the following repositories:Gradle Central Plugin Repository ...

原因

openCV sdk 中使用的是Groovy DSL(build.gradle)

解决方案

将项目中settings.gradle文件中内容拷贝到settings.gradle.kts后将之删除
将openCV sdk Module 下build.gradle改成build.gradle.kts

附:build.gradle.kts

import com.android.build.api.dsl.JniLibsPackaging// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.//
// Notes about integration OpenCV into existed Android Studio application project are below (application 'app' module should exist).
//
// This file is located in <OpenCV-android-sdk>/sdk directory (near 'etc', 'java', 'native' subdirectories)
//
// Add module into Android Studio application project:
//
// - Android Studio way:
//   (will copy almost all OpenCV Android SDK into your project, ~200Mb)
//
//   Import module: Menu -> "File" -> "New" -> "Module" -> "Import Gradle project":
//   Source directory: select this "sdk" directory
//   Module name: ":opencv"
//
// - or attach library module from OpenCV Android SDK
//   (without copying into application project directory, allow to share the same module between projects)
//
//   Edit "settings.gradle" and add these lines:
//
//   def opencvsdk='<path_to_opencv_android_sdk_rootdir>'
//   // You can put declaration above into gradle.properties file instead (including file in HOME directory),
//   // but without 'def' and apostrophe symbols ('): opencvsdk=<path_to_opencv_android_sdk_rootdir>
//   include ':opencv'
//   project(':opencv').projectDir = new File(opencvsdk + '/sdk')
//
//
//
// Add dependency into application module:
//
// - Android Studio way:
//   "Open Module Settings" (F4) -> "Dependencies" tab
//
// - or add "project(':opencv')" dependency into app/build.gradle:
//
//   dependencies {
//       implementation fileTree(dir: 'libs', include: ['*.jar'])
//       ...
//       implementation project(':opencv')
//   }
//
//
//
// Load OpenCV native library before using:
//
// - avoid using of "OpenCVLoader.initAsync()" approach - it is deprecated
//   It may load library with different version (from OpenCV Android Manager, which is installed separatelly on device)
//
// - use "System.loadLibrary("opencv_java4")" or "OpenCVLoader.initDebug()"
//   TODO: Add accurate API to load OpenCV native library
//
//
//
// Native C++ support (necessary to use OpenCV in native code of application only):
//
// - Use find_package() in app/CMakeLists.txt:
//
//   find_package(OpenCV 4.7 REQUIRED java)
//   ...
//   target_link_libraries(native-lib ${OpenCV_LIBRARIES})
//
// - Add "OpenCV_DIR" and enable C++ exceptions/RTTI support via app/build.gradle
//   Documentation about CMake options: https://developer.android.com/ndk/guides/cmake.html
//
//   defaultConfig {
//       ...
//       externalNativeBuild {
//           cmake {
//               cppFlags "-std=c++11 -frtti -fexceptions"
//               arguments "-DOpenCV_DIR=" + opencvsdk + "/sdk/native/jni" // , "-DANDROID_ARM_NEON=TRUE"
//           }
//       }
//   }
//
// - (optional) Limit/filter ABIs to build ('android' scope of 'app/build.gradle'):
//   Useful information: https://developer.android.com/studio/build/gradle-tips.html (Configure separate APKs per ABI)
//
//   splits {
//       abi {
//           enable true
//           universalApk false
//           reset()
//           include 'armeabi-v7a' // , 'x86', 'x86_64', 'arm64-v8a'
//       }
//   }
//plugins {id("com.android.library")id("org.jetbrains.kotlin.android")
}val openCVersionName = "4.7.0-dev"
val openCVersionCode = ((4 * 100 + 7) * 100 + 0) * 10 + 0println("OpenCV: " + openCVersionName + " " + project.buildscript.sourceFile)android {namespace = "org.opencv"compileSdk = 34defaultConfig {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 = falseproguardFiles(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 {
}
http://www.lryc.cn/news/278466.html

相关文章:

  • 【微服务】 Spring cold、Kubernetes、Service mesh
  • 【scala】编译build报错 “xxx is not an enclosing class“
  • vue3+ts+vite项目从0 搭建,配置安装router/pinia/element-plus/scss等
  • 华为OD机试 - 矩阵匹配(Java JS Python C)
  • 使用ffmpeg实现音频静音修剪
  • Java项目调试实战:如何高效调试Spring Boot项目中的GET请求,并通过equalsIgnoreCase()解决大小写不一致问题
  • Google Pixel 与 iPhone手机:哪个更好?
  • ddos攻击会让服务器受到什么影响?-速盾网络(sudun)
  • NSSCTF Interesting_include
  • IPv6路由协议---IPv6动态路由(OSPFv3-5)
  • GPT Store开业大吉:一场AI技术与创新的盛宴
  • Linux---gcc编译
  • 使用阿里云镜像创建一个Spring Boot项目
  • 工智能基础知识总结--词嵌入之Word2Vec
  • redis stream restTemplate消息监听队列框架搭建
  • 【期末不挂科-C++考前速过系列P1】大二C++第1次过程考核(3道简述题&7道代码题)【解析,注释】
  • 游戏开发中,你的游戏图片压缩格式使用ASTC了吗
  • 【PostgreSQL】数据查询-概述
  • element input组件自动失去焦点问题解决
  • 鸿蒙Harmony--状态管理器-@Observed装饰器和@ObjectLink装饰器详解
  • pytorch安装
  • GBASE南大通用系统目录表
  • RPCMS跨站脚本漏洞(xss)
  • Linux进阶命令使用
  • 重定位,进程的创建,线程相关
  • Java填充Execl模板并返回前端下载
  • ChatGPT本地部署,学习记录
  • Find My游戏手柄|苹果Find My技术与手柄结合,智能防丢,全球定位
  • 2024美赛数学建模思路 - 复盘:光照强度计算的优化模型
  • 【Deep Dive: AI Webinar】开放 ChatGPT - 人工智能开放性运作的案例研究