rules_android icon indicating copy to clipboard operation
rules_android copied to clipboard

Support overriding debuggable in AndroidManifest #13801

Open EdbertChan opened this issue 1 year ago • 4 comments
trafficstars

Background

Similar to https://github.com/bazelbuild/bazel/pull/13801, the only way to get a non debuggable-apk debuggable="false" is to use --compilation-mode opt which will invalidate the entire dep graph.

Changes

The drawback of this diff is that unlike what exists in Bazel upstream, the source of truth for the "debuggable" flag of the AAPT2 command is not what is in the AndroidManifest.xml itself but whatever is in manifest_values in the BUILD file.

If no value, we fallback to the compilation-mode opt behavior.

Usage

android_binary(
    name = "app",
    dex_shards = 10,
    manifest = "src/bazel/AndroidManifest.xml",
    manifest_values = {
        "minSdkVersion": "19",
        "appName": "...",
        "applicationId": "...",
        "debuggable": "false",
    },
    multidex = "native",
    visibility = ["//visibility:public"],
    deps = ["..."],
)

EdbertChan avatar Jun 05 '24 19:06 EdbertChan

Per @restingbull (Corbin) offline conversation, the dependency on Compilation.OPT was a matter of convenience from inside of Google. Supposedly, few/nobody who was working on building with the debuggable flag build cared about release so full invalidation was not a problem.

If you weren't building an optimized binary, you should not be building a release anyway since release should be optimized.

Outside of Google, that may not be the case. Some developers very specifically want to work on performance.

EdbertChan avatar Jun 08 '24 21:06 EdbertChan

Hey @EdbertChan, now that starlarkification + tools migration are done, I think we have the bandwidth to try out this CL internally. Could you rebase your fork so that the (now-fixed) BazelCI presubmit can run again?

ted-xie avatar Oct 17 '24 21:10 ted-xie

@ted-xie Looks like they passed

EdbertChan avatar Dec 04 '24 23:12 EdbertChan

@EdbertChan I had some spare cycles and ended up adding the extra flag along with its plumbing. From a very quick ad hoc test, it seems to work on my end.

ted-xie avatar Jan 27 '25 18:01 ted-xie