I have been trying to import opencv-android-sdk to my Bazel project but I am not able to do it.
I tried the this answer on SO but while building my project I get errors that
error: package org.opencv.android does not exist
答案 0 :(得分:1)
我发现Maven中有一个opencv-android
artifact。
您可以使用rules_jvm_external
来依赖它。
在您的WORKSPACE
文件中,指定依赖关系以及其他外部依赖关系:
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"org.opencv:opencv-android:1.0.1",
# ...
],
repositories = [
"https://maven.google.com",
"https://jcenter.bintray.com",
],
)
然后,在包含Android目标的BUILD
文件中,取决于OpenCV目标:
android_library(
name = "my_lib",
custom_package = "com.example.bazel",
srcs = glob(["java/com/example/bazel/*.java"]),
manifest = "java/AndroidManifest.xml",
resource_files = glob(["res/**"]),
deps = [
"@maven//:org_opencv_opencv_android",
],
visibility = ["//src/test:__subpackages__"]
)
最后,您应该能够在Android Java代码中引用类似org.opencv.core.Core
的类。
P.S。考虑将所有maven_jar
和gmaven_rules
/ gmaven_artifact
切换为使用rules_jvm_external
。不赞成使用以前的Maven规则,而推荐使用rules_jvm_external
。