-
Notifications
You must be signed in to change notification settings - Fork 296
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
Linting not working in Android Studio using rules_jvm_external #681
Comments
Probably this. But if rules_jvm_external has the providers that we expect, then it should work. |
Opened an issue here: bazelbuild/rules_jvm_external#118 |
I just tried out rules_jvm_external, and it does work for me. The problem is probably with your setup. What version of the bazel plugin are you using? |
Also if you can share your .bazelproject file. |
Or even your whole project. |
also, which version of rules_jvm_external is that? |
|
Thanks for the fast answers! That's good news, then I have to figure out what's wrong with my environment. The latset Bazel plugin I've tried was built locally on commit 219d81d (latest master yesterday) using instructions in README. Since I cant find any bazel plugin inside Android Studio IDE using default repositories. I'm working on a private repository outside Github. So unfortunately, I can't share the whole project that easily. However, here are some more snippets from files that you asked about. WORKSPACE:
.bazelproject:
|
Do I need to configure something inside IDE except installing Bazel plugin? |
When you run |
Nope, not a single error.
I see this. Shouldn't there be any jars beside "res" when expanding? It also seems like there are some missing libraries compared to the list of installed with rules_jvm_external. |
The Android SDK is okay. Mine looks like that too. My maven jars show up as classes_and_libs_merged, and you don't have those, but it looks like you do have them as individual jars. |
Alright, do you have any clue why the linting isn't working for me? |
Could you try importing one of the Android project examples in
rules_jvm_external and see if it works?
https://github.com/bazelbuild/rules_jvm_external/tree/master/examples
…On Thu, Apr 18, 2019 at 12:59 PM Alexander Ernfridsson < ***@***.***> wrote:
Alright, do you have any clue why the linting isn't working for me?
Is there something I could try?
Can it be how project structure related? (e.g. how the build files looks
like)
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#681 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACU6DRY7OOAG2NR5S3RVH3PRCSIRANCNFSM4HGV5TDA>
.
|
I've tried it now and I have the same problem. Imported Bazel project in Build output: .bazelproject:
Modified WORKSPACE:
When I build project in Android Studio using the "play" button it succeeds:
Sync output (no errors or warnings what I can see):
Is there any cache related to Bazel plugin that I could try clear? |
I thought these maven jars were just downloaded off of maven. Why would the Android SDK affect them at all? Unless they also exist in the Android SDK, and they're conflicting somehow? |
These aar and jar files don't live in the SDK. There are some that do, but they are not these artifacts. |
I have no idea what I am doing, I am just trying everything I can and showing the result for you in hope that you can help me figure it out. I have absolutely no experience with intellij plugins or how Android Studio IDE works. I opened AS after I deleted SDK and then installed the SDK inside IDE, restarted IDE and then when I synced once. After that "classes_and_libs_merged" popped up for androidx.drawerlayout and when I imported it in java file, linting started working for that lib. It's possible that reinstalling SDK had nothing to do with anything. |
After some more digging, it seems like "External Libraries" contains stuff from alot of different directories.This is however expected since they have different origins, some comes from SDK, others from bazel toolchain or rules_jvm_external, right? Problem is that libraries fetched/extracted by rules_jvm_external exists at multiple directories. At some places the libraries only contain resources of external libraries while others contains both resources and sources/jar/aar. Here are some examples of the locations of libraries under External Libraries:
The devil seems to be I think both Is there any way of changing priority of directories searched? |
I found the Android Studio system log (
They appear for once for each rules_jvm_external library when doing a non incrementally sync in IDE. |
I finally found a solution to my problem.
//Original
@Override
public boolean test(BlazeLibrary blazeLibrary) {
if (!(blazeLibrary instanceof BlazeJarLibrary)) {
return true;
}
BlazeJarLibrary jarLibrary = (BlazeJarLibrary) blazeLibrary;
ArtifactLocation location = jarLibrary.libraryArtifact.jarForIntellijLibrary();
String configurationLessPath = location.getRelativePath();
return !aarJarsPaths.contains(configurationLessPath);
}
// Disabled
@Override
public boolean test(BlazeLibrary blazeLibrary) {
return true;
} ... both jar (classes_and_libs_merged.jar) and aar files shows up in External Libraries and linting works like a charm! Even layout preview started working (never worked for me with Bazel before I started using rules_jvm_external either). |
Thanks for the in-depth investigation. My
Did you carry the project over from a previous version of the bazel plugin? If that's the case, then a freshly imported project with the latest version of the bazel plugin might not have had the same problem. Or just manually deleting
The stuff under |
Yes I did at first, but I have tried removed the whole .aswb directory and reimport the projects more than once. But it did not change anything for me... My $ ls -a1 .aswb/.blaze/libraries/
.
..
annotation-1.0.2_75002acf.jar
annotation-1.0.2-sources_49c97a3a-src.jar
classes_and_libs_merged_15dd0009.jar
classes_and_libs_merged_31712fa8.jar
classes_and_libs_merged_34f7b2dc.jar
classes_and_libs_merged_5f96c948.jar
classes_and_libs_merged_6be66f86.jar
classes_and_libs_merged_9189ed62.jar
classes_and_libs_merged_9dd7f246.jar
classes_and_libs_merged_a344a90e.jar
classes_and_libs_merged_ac6aa512.jar
classes_and_libs_merged_ae7e3588.jar
classes_and_libs_merged_b229d588.jar
classes_and_libs_merged_c0127708.jar
classes_and_libs_merged_d73199c4.jar
classes_and_libs_merged_dd51e5a8.jar
grpc-core-1.19.0_5a0f8819.jar
grpc-core-1.19.0-sources_67f3ed84-src.jar
grpc-protobuf-lite-1.19.0_a9c159c5.jar
grpc-protobuf-lite-1.19.0-sources_f33f5330-src.jar
grpc-stub-1.19.0_87357c39.jar
java_compiler_1533de39.jar
jdk_compiler_81756a6a.jar
libsmartome_proto_java-hjar_fb8f9718.jar
libsmartome_proto_java-src_a5f97359-src.jar
lifecycle-common-2.0.0_f1639f88.jar
protobuf-lite-3.0.1_eda66f3d.jar But this is with the fix I described above. Without the fix, it contain the all the files but
$ find .aswb/.blaze/aar_libraries/ -type f -name "*jar"
# Nothing
$ find .aswb/.blaze/aar_libraries/ -type f -name "*aar"
# Nothing EDIT: Sorry if you already read this. Mixed aar_libraries and libraries directory... Now fixed! |
FWIW, I can reproduce the issue. A fresh import of rules_jvm_external/examples/android_local_test using the internal plugin build also results in #681 (comment) My
My
|
Okay, I reproduce and figured out the problem. Fix should be available shortly. |
Android Studio plugin cannot resolve external libraries imported by bazelbuild/rules_jvm_external. I've tried so many setting and configurations, reinstalling android studio and plugin and clicked on the sync button (all the variants) without any success.
This is what I see when I open any source file (java) in my project:
![cannotresolvsymbol](https://user-images.githubusercontent.com/8659631/56303429-306ea380-613c-11e9-81e0-1e60bb5a0ad4.png)
BUILD file:
Building and installing on emulator have always worked fine in IDE but I can't get the IDE linting to work (only those imported by rules_jvm_external) which make Android Studio pretty useless with Bazel.
Am I doing something wrong?
Is it intended to not work?
Missing support for rules_jvm_external?
Please enlighten me!
OS: Linux (Ubuntu 18.04)
Bazel version: 0.24.0
Andorid Studio: 3.3.0 and 3.4.0-RC3
Bazel plugin: Many different commits on HEAD:master during the past months.
Language: Java (Android)
Best Regards
The text was updated successfully, but these errors were encountered: