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_binary rules not compiling due to missing aapt and apkbuilder files #523

Closed
XperielIndigo opened this issue Oct 22, 2015 · 5 comments
Assignees

Comments

@XperielIndigo
Copy link

Hi everyone,

I've been building android_binaries for a few months now, however, to make it work I've always had to modify my dev environment to use hard coded paths for accessing the aapt and apkbuilder tools.

See #392 for the fix I use.

In the last comment of that issue I ask whether there is a cleaner way to do this that can be incorporated into bazel directly (instead of me patching my clone).

Has there been any progress on this issue? Or can someone tell me how to get bazel head to compile android_binaries appropriately (i.e. without the missing file errors)?

Cheers
Indigo

@damienmg
Copy link
Contributor

@ahumesky @lberki: this bug was unanswered for 26 days...

@ahumesky
Copy link
Contributor

So is the error still that the path looks like
/private/var/tmp/_bazel_root/373fe016a982fda7060b14fd6dde0bd1/Master/bazel-out/local_darwin-fastbuild/bin/external/androidsdk/aapt_binary.runfiles//private/var/tmp/_bazel_root/373fe016a982fda7060b14fd6dde0bd1/Master/bazel-out/local_darwin-fastbuild/bin/external/androidsdk/build-tools/21.1.2/aapt, i.e. there is an absolute path in there ("aapt_binary.runfiles//private....")?

Lets see what that little generated script is doing. Could you revert your changes to android_sdk_repository_template.txt, and then add the x option to bash here:

so that it's "#!/bin/bash -eux", then try to build your project, then paste the output here? You should see some output like

INFO: From Processing resources:
Error: + BINARY=external/androidsdk/aapt_binary
Error: ++ dirname external/androidsdk/aapt_binary
Error: + DIRNAME=external/androidsdk

It seems like dirname might be doing something unexpected, or perhaps it's different somehow on mac than on linux.

@XperielIndigo
Copy link
Author

Any update?

@lberki
Copy link
Contributor

lberki commented Dec 11, 2015

Hm, this is kind of odd. Now that I look at this output:

https://gist.github.com/XperielIndigo/a564fb57fdaa4093e67a

aapt apparently gets executed in the target configuration as opposed to the host one. The line:

/private/var/tmp/_bazel_root/eeba38b9814c9e09ce33cdb3fd7c34f8/Master/bazel-out/local_darwin-fastbuild/bin/external/androidsdk/aapt_binary.runfiles//private/var/tmp/_bazel_root/eeba38b9814c9e09ce33cdb3fd7c34f8/Master/bazel-out/local_darwin-fastbuild/bin/external/androidsdk/build-tools/21.1.2/aapt

indicates that the shell prefix removal command BINARY=${0##*-out/host/bin/} didn't work and thus you ended up with an absolute path containing local_darwin-fastbuild/bin (host/bin would have been stripped out) here.

Sure I can fix this by changing that shell substitution command a little, but I wonder how that's possible. @gregestren , any clever ideas? The android_sdk rule depends on aapt in the host configuration as it should:

https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java#L325

@XperielIndigo , could you tell us how to reproduce this thing? I'm not very smart, so please be explicit and clear :)

@lberki
Copy link
Contributor

lberki commented Dec 11, 2015

Okay, I sent out a change that I think fixes it. All you need to do is to replace

"BINARY=$${0##*-out/host/bin/}",

with

"BINARY=$${0#*-out/*/bin/}",

in android_sdk_repository_template.txt, but I'd like to figure out first why this is happening. aapt should never be in the target configuration...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants