Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android_library aar target does not include jni so files #1547

Closed
lilac opened this issue Jul 22, 2016 · 4 comments
Closed

android_library aar target does not include jni so files #1547

lilac opened this issue Jul 22, 2016 · 4 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) type: feature request
Milestone

Comments

@lilac
Copy link

lilac commented Jul 22, 2016

Bazel version: 0.2.3

  1. Add an android_library rule
  2. Make the rule depends on a cc_library, which wraps a cc_binary that outputs a so file.
  3. Build the aar target, but the aar does not include the dependent so files.

If I change the android_library to android_binary, then the generated apk contains the so file without any problem.

@ahumesky
Copy link
Contributor

This is because, currently, the aar output of android_library contains the output of only that target, not the transitive closure:
http://www.bazel.io/docs/be/android.html#android_library_implicit_outputs
Additionally, if you had an android_library A depend on an android_library B, the aar of A will not contain anything from B. We'd like to make it possible to output the transitive closure for the aars, but there are resource processing issues, and we won't likely get to it for a while.

@ahumesky ahumesky added type: feature request P3 We're not considering working on this, but happy to review a PR. (No assignee) category: rules > android labels Jul 22, 2016
@lilac
Copy link
Author

lilac commented Jul 26, 2016

@ahumesky Thanks for the explanation. Is there any workarounds for it at the moment?

@ahumesky
Copy link
Contributor

You might be able to get pretty far by wrapping the android_library in an android_binary rule, then using the _deploy.jar implicit output of android_binary to get the classes.jar, and extracting the native libs and resources and assets from the apk, and putting that together in a genrule or a skylark rule. The tricky part is getting R.txt and the AndroidManifest, because those are not implicit outputs of andorid_binary. R.txt is an implicit output of android_library, but I don't think it's going to include transitive dependencies. You might have to write a wrapper script that will take the right things out of bazel-bin and assemble the aar.

@ahumesky ahumesky added P2 We'll consider working on this in future. (Assignee optional) and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) labels Dec 8, 2016
@ahumesky ahumesky modified the milestone: 0.6 Dec 12, 2016
@aj-michael
Copy link
Contributor

This is a duplicate of #348.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) type: feature request
Projects
None yet
Development

No branches or pull requests

3 participants