Skip to content

LSP can't find android, androidx reference #411

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

Closed
Savuth-S opened this issue Jan 14, 2023 · 6 comments
Closed

LSP can't find android, androidx reference #411

Savuth-S opened this issue Jan 14, 2023 · 6 comments

Comments

@Savuth-S
Copy link

Savuth-S commented Jan 14, 2023

I'm using Nvim with this LSP and for some reason it can't recognize the android and androidx packages and I'm not sure what I'm doing wrong.

image

@themkat
Copy link
Collaborator

themkat commented Jan 15, 2023

Hard to say whats wrong without seeing the language server logs. My main guess is that you use Gradle, and the dependency resolution fails. As this is Android, my main guess is that you might have an error like I describe here: #376 (comment)

If you can share your language server logs (during project initialisation) that would be great :) Then we can hopefully see what the issue is in your case.

@Savuth-S
Copy link
Author

Savuth-S commented Jan 17, 2023

Hard to say whats wrong without seeing the language server logs. My main guess is that you use Gradle, and the dependency resolution fails. As this is Android, my main guess is that you might have an error like I describe here: #376 (comment)

If you can share your language server logs (during project initialisation) that would be great :) Then we can hopefully see what the issue is in your case.

Heres the log, ill be checking the thread you mentioned. thank you.

@Savuth-S
Copy link
Author

Savuth-S commented Jan 17, 2023

After reading the log I've figured out its probably my java version, however I do have JAVA 11 installed, and I already tried changing the environment variable and adding the bin to the path but LSP still wont take, I even uninstalled java 19 and still refuses to use java 11. Not sure if I'm doing something wrong

@Savuth-S
Copy link
Author

Yes that was it, it got fixed after setting the env to the java 11 on the lsp setup in my .vimrc

image

@fmorroni
Copy link

Hi, I'm having this same issue but it wasn't fixed by adding the cmd_env setup option. I'm trying to work on a small android project but I get unresolved reference errors everywhere.
Any idea what else could be the problem? I tried looking at the lsp logs but I could't decipher much out of it.

@BPplays
Copy link

BPplays commented Feb 12, 2025

here is a similar config i made if anyone wants to copy paste

local lspconfig = require("lspconfig")
local java_path = "java/path"

lspconfig["kotlin_language_server"].setup({
	on_attach = on_attach,
	cmd_env = {JAVA_HOME=java_path},
	root_dir = lspconfig.util.find_git_ancestor
})

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

No branches or pull requests

4 participants