rules_android
rules_android copied to clipboard
Support overriding debuggable in AndroidManifest #13801
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 = ["..."],
)
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.
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 Looks like they passed
@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.