gpt4 book ai didi

android - OpenCV 4.1.0 Android Sdk 找不到匹配的配置Android studio

转载 作者:行者123 更新时间:2023-11-29 16:30:52 34 4
gpt4 key购买 nike

我正在尝试将 OpenCV 4.1.0 Android sdk 导入我的 android studio 项目并出现 gradle 构建错误(使用 OpenCV 4.0.1 Android SDK 构建成功)。

Unable to find a matching variant of project :opencv:
- Variant 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'release' and found incompatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
...

这是我的应用程序 build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "ml.nopain.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
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'
implementation project(':opencv')
}

还有我的 opencv build.gradle:

apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "org.opencv"
minSdkVersion 15
targetSdkVersion 28
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}

dependencies {
}

当我尝试导入 OpenCV 4.0.1 Sdk 时,gradle 构建成功,没有任何错误。
我可以尝试做些什么来解决问题?感谢您的帮助!

解决方案感谢 Ranjan Kumar,我找到了解决这个问题的方法!只需将 'com.android.application' 更改为 'com.android.library'

最佳答案

基于 gradle,您似乎正在尝试将 opencv 构建为应用程序。您应将 opencv 作为模块(库)并包含在您的实际应用中。

有一份将 opencv 与 android 集成的指南。 https://android.jlelse.eu/a-beginners-guide-to-setting-up-opencv-android-library-on-android-studio-19794e220f3c

关于android - OpenCV 4.1.0 Android Sdk 找不到匹配的配置Android studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55692634/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com