Skip to content

uses-permissions in AndroidManifest.xml are not exported to App #5411

@steeve

Description

@steeve

Description of the problem / feature request:

As per the documentation, uses-permissions attributes are never exported to the main app. What is the rationale behind this decision?
Is there any way to have an android_library export its permissions to an app that includes it ?

Thanks!

What operating system are you running Bazel on?

macOS

What's the output of bazel info release?

release 0.14.1-homebrew

Have you found anything relevant by searching the web?

They are manually removed here:

private static final String[] PERMISSION_TAGS =
new String[] {"uses-permission", "uses-permission-sdk-23"};
private static final StdLogger stdLogger = new StdLogger(StdLogger.Level.WARNING);
private static final Logger logger = Logger.getLogger(ManifestMergerAction.class.getName());
private static Options options;
private static Path removePermissions(Path manifest, Path outputDir)
throws IOException, ParserConfigurationException, TransformerConfigurationException,
TransformerException, TransformerFactoryConfigurationError, SAXException {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = docBuilder.parse(manifest.toFile());
for (String tag : PERMISSION_TAGS) {
NodeList permissions = doc.getElementsByTagName(tag);
if (permissions != null) {
for (int i = permissions.getLength() - 1; i >= 0; i--) {
Node permission = permissions.item(i);
permission.getParentNode().removeChild(permission);
}
}
}
// Write resulting manifest to the output directory, maintaining full path to prevent collisions
Path output = outputDir.resolve(manifest.toString().replaceFirst("^/", ""));
Files.createDirectories(output.getParent());
TransformerFactory.newInstance()
.newTransformer()
.transform(new DOMSource(doc), new StreamResult(output.toFile()));
return output;
}

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)team-AndroidIssues for Android teamtype: feature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions