gpt4 book ai didi

android - 在 Android Studio 项目中包含 OpenCV 会产生 'Unresolved dependencies' 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:22:23 27 4
gpt4 key购买 nike

我正在尝试使用 this 在我的 Android Studio 项目中包含 OpenCV一步一步的指导。但是,在将 OpenCV 添加为模块依赖项(指南中的第 4 步)后,Gradle 项目同步失败并出现以下错误:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :openCVLibrary410.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :openCVLibrary410.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :openCVLibrary410.
Show Details
Affected Modules: app

我找到了 this related question并尝试通过添加调试字段来调整 openCV build.gradle 中的 buildTypes,但它没有改变任何东西。我还尝试如下调整应用程序的 build.gradle

    buildTypes {
release {
...
}
debug {
matchingFallbacks = ['release']
}
}

(以及几个略有不同的版本,因为我不完全确定我在那里做什么)但没有帮助。我还尝试将 OpenCV 库的构建变体设置为发布而不是调试,但这导致了以下错误:

Unable to find a matching variant of project :openCVLibrary410:
- Variant 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible 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-api' and found compatible value 'java-api'.
- Variant 'debugBundleElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Required org.gradle.usage 'java-api' and found incompatible value 'android-bundle'.
- Variant 'debugMetadataElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible 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 'Metadata'.
- Required org.gradle.usage 'java-api' but no value provided.
- Variant 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible 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-api' and found incompatible value 'java-runtime'.
- Variant 'releaseApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
- Variant 'releaseBundleElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Required org.gradle.usage 'java-api' and found incompatible value 'android-bundle'.
- Variant 'releaseMetadataElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
- Required org.gradle.usage 'java-api' but no value provided.
- Variant 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
- Required org.gradle.usage 'java-api' and found incompatible value 'java-runtime'.

知道如何解决这个问题吗?

最佳答案

我终于通过改变线路解决了这个问题

应用插件:'com.android.application'

在导入OpenCV模块的build.gradle文件中

应用插件:'com.android.library'

并删除同一个 gradle 文件中的 defaultConfig 字段。我找到了这个解决方案 here .

关于android - 在 Android Studio 项目中包含 OpenCV 会产生 'Unresolved dependencies' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55601598/

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