android_library ignores _renamed manifest and still links invalid _generated manifest package

未关闭
#445 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 6 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
android, java
领域
build-system

调研方向

从 android_library 的 manifest 生成和 manifest 合并入口开始,然后追踪为什么 _generated 和 _renamed 都会到达 AAPT2。完成的标准是:custom_package 或 manifest 阻止无效的生成 package 被链接,并且只有正确的 _renamed manifest 会传递给 AAPT2。

由索引模型根据 Issue 内容生成。

描述

android_library generates an AndroidManifest with an invalid package name derived from the Bazel target name, and still uses the _generated manifest during manifest merging, even though the _renamed manifest has the correct package.

This results in AAPT2 linking failure.

Actual manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest/>

Build file:

android_library(
    name = "lib-facets-constant-debug",
    srcs = glob([
        "src/main/kotlin/com/arga/merchant/lib/facets/constant/**/*.kt",
    ]),
    custom_package = "com.arga.merchant.lib.facets.constant",
    lint_options = {
        "enabled": True,
        "baseline": "lint-baseline.xml",
    },
    manifest = "src/main/AndroidManifest.xml",
    visibility = [
        "//visibility:public",
    ],
    deps = [
        "//:parcelize",
        "@debug_maven//:androidx_annotation_annotation",
    ],
)

Generated manifest (_generated):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="lib-facets.lib-facets-constant">
   <application />
</manifest>

Renamed manifest (_renamed):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.arga.merchant.lib.facets.constant" />

Expected behavior:

  • When custom_package or manifest is provided, rules_android should not generate or link a manifest with an invalid package name
  • _renamed manifest should be the only manifest passed to AAPT2

Actual behavior:

  • AAPT2 still links the _generated manifest
  • The invalid generated package causes build failure
主要语言
Java
星标
205
派生
113
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bazelbuild/rules_android 的其他 Issue

查看 bazelbuild/rules_android 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。