使用Bazel构建Android项目时@Keep依赖可见性问题及解决
Bazel Android开发:@Keep注解依赖可见性问题解决
问题背景
作为Bazel Android开发新手,为防止代码被混淆,我在代码中添加了@Keep注解,需要导入import androidx.annotation.Keep;依赖。项目platform/android/car/src/main路径下的BUILD文件中,android_library目标配置了依赖@maven//:androidx_annotation_annotation。
报错情况
即使将该依赖的visibility从//car:__subpackages__修改为//visibility:public,依然触发如下报错:
ERROR: /workspace/platform/android/car/src/main/BUILD:24:16: in android_library rule //car/src/main:car: target '@maven//:androidx_annotation_annotation' is not visible from target '//car/src/main:car'. Check the visibility declaration of the former target if you think the dependency is legitimate ERROR: /workspace/platform/android/car/src/main/BUILD:24:16: Analysis of target '//car/src/main:car' failed
解决步骤
修改platform/android/WORKSPACE文件中maven_install块内的androidx.annotation:annotation版本,将1.6.0替换为1.5.0,问题得以解决。
内容的提问来源于stack exchange,提问作者rmh
相关产品推荐
相关产品推荐

