문제 설명
Bazel을 사용하는 프로젝트에 OpenCV android‑sdk를 가져오는 방법은 무엇입니까? (How to import OpenCV android‑sdk to my project which is using Bazel?)
opencv‑android‑sdk를 내 Bazel 프로젝트로 가져오려고 했지만 할 수 없습니다.
SO에서 이 답변을 시도했지만 내 프로젝트를 빌드하는 동안 오류가 발생했습니다.
오류: org.opencv.android 패키지가 존재하지 않습니다.
참조 솔루션
방법 1:
I see that there's an opencv‑android
artifact on Maven.
You can depend on this using rules_jvm_external
.
In your WORKSPACE
file, specify the dependency along with the other external dependencies:
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",
],
)
Then, in your BUILD
file containing your Android targets, depend on the OpenCV target:
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__"]
)
Finally, you should be able to reference classes like org.opencv.core.Core
in your Android Java code.
P.S. consider switching all your maven_jar
and gmaven_rules
/gmaven_artifact
to use rules_jvm_external
. The former Maven rules have been deprecated in favor of rules_jvm_external
.
(by sonudelhikkc、Jin)