Status Update
Comments
pa...@gmail.com <pa...@gmail.com> #2
Forgot to add the second screenshot. Here it is
aa...@google.com <aa...@google.com>
an...@google.com <an...@google.com>
kd...@google.com <kd...@google.com> #3
Hi! I don't seem to be able to reproduce this behavior. As far as the resolution goes, these are treated exactly the same under the hood so I'm not sure how there would be a discrepancy.
I did notice that in your example, you are missing a semicolon after "age" in the PersonView
, and when I left that out, I got the same issue with things not resolving, but once I put the semicolon then everything worked as expected. Just want to verify that that's not the cause.
pa...@gmail.com <pa...@gmail.com> #4
The missing semicolon is a typo from my part and shouldn't change the behaviour in the issue. In my own code, I also have a semicolon. Unfortunately I don't seem to be able to edit the issue description.
Maybe the issue only arises in certain situations? I gave a simplified version of the problem with simple objects, but in my project I have database view on joins. I made sure that the simplified version of the issue also arises syntax errors in my own project though. Maybe something else clashes with it?
At the moment of writing, there are 2 other persons who also seem to have the issue (looking at the "I am impacted" vote count), so it seems that I'm not the only one with the issue, but weird that you can't seem to reproduce with my example.
Let me try to reproduce the issue in a clean project. Give me day or two for that.
kd...@google.com <kd...@google.com> #5
Thank you! That will help immensely.
hu...@gmail.com <hu...@gmail.com> #6
pa...@gmail.com <pa...@gmail.com> #7
I created a fresh project, and I still got the error. I did find something interesting though, and that is that the issue occurs (for me at least) when I add the @Dao
annotation. Before that, I do not get the error and the columns and view in "SELECT name FROM PersonView"
are actually linking with the field and class respectively.
What I mean with that, is when you click with your mouse wheel (or ctrl + b) on name
, it actually goes to the name
field in PersonView
. And when you click on PersonView
it also actually goes to that class. But after I add @Dao
, I get the error as described above (name
and PersonView
become red and get "Cannot resolve symbol ..."
).
So it seems as if @Dao
is breaking the connection / link to the class? How far did you setup a project to reproduce the issue? Are you using the same versions as described in the issue? In my clean project, I used higher versions:
AGP: 8.7.3
Gradle: 8.9
The rest is the same:
Java: 18
OS: Windows 11
Studio Build: Ladybug | 2024.2.1 Patch 3
So even in higher versions of AGP and Gradle, the issue still persists. I used higher versions in my clean project to eliminate the possibility that the issue might have been fixed in a higher version.
I can share the setup project on GitHub if you'd like to. But don't know whether it will help since the issue seems to relate to the code editor, and not necessarily to the code itself. I didn't really create anything new except a database class, DAO class, an entity class and a view class.
kd...@google.com <kd...@google.com> #8
Is the project otherwise empty? I will attempt to reproduce from a brand new project with nothing else.
pa...@gmail.com <pa...@gmail.com> #9
Except for a MainActivity
, the project is empty.
kd...@google.com <kd...@google.com> #10
Great, thank you, I will investigate this today :)
kd...@google.com <kd...@google.com> #11
I'm on
AGP: 8.7.3 Gradle: 8.11.1
and I am not able to reproduce.
Switching Gradle to 8.9 now.
kd...@google.com <kd...@google.com> #12
Still no dice :(
pa...@gmail.com <pa...@gmail.com> #13
I wonder what the problem is then? Is it some kind of setting inside the editor itself that causes issues?
Do you guys do debug sessions? That way I can show the issues on-the-fly and maybe you can instruct me to debug my Android Studio locally (as far as that's possible)?
kd...@google.com <kd...@google.com> #14
Can you reproduce the issue and then grab the idea.log and attach it here? (select Help > Show Log in Explorer)
pa...@gmail.com <pa...@gmail.com>
kd...@google.com <kd...@google.com> #15
OK. I've gotten a Windows (10) environment set up. I have this exact version of Android Studio with that version of AGP and Gradle. I even installed the custom Lombok plugin you have. I cannot get this to reproduce. I am attaching my project as a .zip so you can open it and tell me if the issue reproduces with it. If not, would you be willing to export your minimal repro project to a .zip and attach it so that I can see if it reproduces locally?
pa...@gmail.com <pa...@gmail.com> #16
Sorry, exactly on the day that you replied, I was abroad for a few weeks, so I didn't have access to my computer. Now I'm back home! (Saying this because I don't want you think I forgot about the issue)
Good news though! The issue does not appear in the project you sent! So that means we at least have 2 projects to compare with each other! At first sight, the immediate difference that I can find is that my project uses only Java, and your project uses mostly Kotlin. But don't know how that could influences this bug.
I had to change two things in your project though, as Gradle didn't immediately build on my end. I changed:
- In
libs.version.toml
(and consequently thedependencies
inbuild.gradle.kts
), I had to add theroom-runtime
library, as theroom-common
library that you used didn't recognizeandroidx.room.RoomDatabase
inPersonDatabase
- In
build.gradle.kts
, I had to changejvmTarget
inkotlinOptions
from11
to17
Attached my own project here as you asked!
kd...@google.com <kd...@google.com> #17
Thank you! I will continue to investigate.
kd...@google.com <kd...@google.com> #18
So it repros here with your project. Check it out though - if you comment out public abstract PersonDAO personDAO();
in PersonDB.java
, does the issue disappear? It does for me. I will keep looking into it.
pa...@gmail.com <pa...@gmail.com> #19
The issue also disappears for me when commenting out public abstract PersonDAO personDAO();
. If you comment out @Dao
in PersonDAO.java
, the issue also disappears.
kd...@google.com <kd...@google.com> #20
Good news - I figured it out :)
Fix incoming!
pa...@gmail.com <pa...@gmail.com> #21
Amazing! Super happy to hear that!
Care to explain exactly what was wrong (if you're allowed to)? On a very high-level overview, as I obviously don't know how Android Studio works under the hood. But did it have something to do with the language (as I suggested in one of the above messages)?
I'm especially very curious why it was so hard for you to reproduce it.
kd...@google.com <kd...@google.com> #22
it.views.contains(table.psiClass)
Took a while to isolate it to that line, though :) The fact that it worked in the other cases (no @Dao
, not the return type of a method on the @Database) was a freak coincidence and red herring. :/ PersonDAO
-typed fields, or an Optional<PersonDAO>
didn't have the same effect, it was only the return type of methods that mattered.
pa...@gmail.com <pa...@gmail.com> #23
Aha super interesting! Really happy that you found it haha :). This bug has been bothering me for months now lol.
I also found another bug actually, not related to this. Do I need to make a new issue for that or can I give a small description here (it's not a big bug, very similar to another bug I posted earlier).
kd...@google.com <kd...@google.com> #24
New bug pls :)
Yeah, this one was introduced back in 2021 so it's been there a while. Glad you were able to help me fix it!
kd...@google.com <kd...@google.com>
an...@google.com <an...@google.com> #25
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Meerkat Feature Drop | 2024.3.2 Canary 4
- Android Gradle Plugin 8.10.0-alpha04
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
DESCRIBE THE ISSUE IN DETAIL:
In DAO's, we can place
@Query
methods to query the database. When querying entities, there is no problem. But when querying a@DatabaseView
, it gives aCannot resolve symbol ...
error on the table name as well as any columns from the database (in theSELECT
statement, inWHERE
statments, ...).I would like to clarify on the syntax error part, because the query itself runs fine and also correctly fetches the data. The problem is really only on the syntax.
STEPS TO REPRODUCE:
The view is also placed in the database class, i.e.,
@Database(..., views={PersonView.class})
You can see that there are no errors in
getNamesFromPersonTable()
, but ingetNamesFromPersonView
, bothname
andPersonView
in the query are red and when you hover over them, you seeCannot resolve symbol 'name'
andCannot resolve symbol 'PersonView'
respectively.I attached 2 screenshots of the query and the (syntax) error.
Studio Build: Ladybug | 2024.2.1 Patch 3
Version of Gradle Plugin: 8.2.0
Version of Gradle: 8.8
Version of Java: 18
OS: Windows 11