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

ConstraintLayout not available under @androidsdk// #2830

Closed
cpetosky opened this issue Apr 14, 2017 · 6 comments
Closed

ConstraintLayout not available under @androidsdk// #2830

cpetosky opened this issue Apr 14, 2017 · 6 comments

Comments

@cpetosky
Copy link

Description of the problem / feature request / question:

Using WORKSPACE:

android_sdk_repository(
    name = "androidsdk",
    api_level = 25,
    build_tools_version = "25.0.2",
)

bazel query @androidsdk//... | grep constraint gives no results. I do have the constraint layout support installed via SDK manager and I can access constraint layout features in Gradle builds using compile 'com.android.support.constraint:constraint-layout:1.0.1'.

Expected: @androidsdk//com.android.support.constraint:constraint-layout-1.0.1 resolves to the locally-installed constraint layout support.

If possible, provide a minimal example to reproduce the problem:

bazel query @androidsdk//... | grep constraint after installing constraint layout support in your Android SDK should return at least one result.

Environment info

  • Operating System: Mac OS X El Capitan (10.11.6)
  • Bazel version (output of bazel info release): release 0.4.5-homebrew

Have you found anything relevant by searching the web?

No. I did submit a question on StackOverflow but have not gotten any responses.

Anything else, information or logs or outputs that would be helpful?

Please let me know if there's anything relevant I can provide.

@aj-michael
Copy link
Contributor

What is the output of ls $ANDROID_HOME/extras/android/m2repository/com/android/support/constraint/constraint-layout ? Bazel looks inside of $ANDROID_HOME/extras/android/m2repository and creates targets based on the POM files in there.

I'm not sure exactly where Gradle is getting this library from, but I don't think that $ANDROID_HOME/extras/android/m2repository/com/android/support/constraint is in the public android sdk

@cpetosky
Copy link
Author

Ah, I see the issue. The constraint library is stored in $ANDROID_HOME/extras/m2repository, not $ANDROID_HOME/extras/android/m2repository.

$ ls $ANDROID_HOME/extras/m2repository/com/android/support/constraint/constraint-layout
1.0.0-beta4		1.0.1			1.0.2			maven-metadata.xml	maven-metadata.xml.md5	maven-metadata.xml.sha1

There appears to be nothing else in that m2repository directory except for constraint-layout.

I installed the feature via Android Studio's SDK manager and did not manually edit anything in my SDK directory.

@aj-michael
Copy link
Contributor

Hmm, I wonder why the Android SDK did that. If you want to get unblocked, I see three workarounds:

  1. Modify your Android SDK and put constraint-layout in the place that Bazel expects it.
  2. Copy constraint-layout out of the SDK and into your WORKSPACE and use an aar_import rule to wrap it.
  3. Modify Bazel and recompile it. It's actually easier than it sounds to do this. First clone https://github.com/bazelbuild/bazel update this map to include /extras/m2repository: https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java#L224. Then from the root of the github repo, run bazel build //src:bazel. And then alias newbazel=$(pwd)/bazel-bin/src/bazel.

I'll try to add this new path to this list of places that android_sdk_repository looks for the next Bazel release.

@polaroidkidd
Copy link

Ok, so it turns out that, due to what I'm attempting to build, I require the bazel build to work. So I might as well attempt to fix this locally.

@aj-michael, I wanted to ask you about option three. I looked at the code you mentioned but noticed that the map already includes extras/m2repository up at the top, or am I mistaken? If not, how would I change the code to include it? Any help would be greatly appreciated.

@aj-michael
Copy link
Contributor

Hey @polaroidkidd, I fixed this issue 12 months ago in commit b9a2e9d which is why you see that entry in the list.

So if you have a recent bazel release, you should be fine.

However, in the time since this issue was filed, google has actually stopped shipping the newest support libraries inside of the Android SDK. Instead you have to get them from the Google Maven repository. If you want to use the newest constraintlayout, I suggest that you check out https://github.com/aj-michael/gmaven_rules

@polaroidkidd
Copy link

Thank you for your timely reply and support. Much appreciated!

luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
…repositories.

    Fixes bazelbuild/bazel#2830

    RELNOTES: None
    PiperOrigin-RevId: 153367521
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

3 participants