Closed blackjyn closed 2 years ago
I would have expected it to just work out-of-the-box. Does a manual Gradle build succeed? Do you have the Android SDK installed?
manual build via gradle works just fine, I also have Android Studio installed.
But I give SB4 a try because how crazy AS and Intellij on the indexing process even on simple project and I love doing most of things manually via CMD.
and yeah, I know someone succed On this but he is on Emacs rather than SB4. https://jwill.dev/blog/2022/01/26/EmacsAsIDE-Android.html
I tried to follow on SB4 but failed
Since they are using the exact same language server (jdtls) I assume that this is an issue with the server rather than with this plugin. (Its Gradle support is limited, after all)
See here on how to enable debug output. Maybe jdtls outputs an error that helps you to track the issue down.
Is there any plan on improving to support android development with this plugin? I tried many times, it works fine with vscode, all environment variables for android had been set up right, but in sublime still cant work with this plugin.
Or maybe there could be android lsp plugin rather than supporting android development through this java lsp?
This plugin should behave just like "Language Support for Java" for VSCode since it uses the same server under the hood.
If there are differences, I am happy to investigate further but I would need detailed information about the difference, your setup as well as a minimal example/project.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[
"${java_executable}",
"--add-modules=ALL-SYSTEM",
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
"--add-opens",
"java.base/java.lang=ALL-UNNAMED",
"--add-opens",
"java.base/sun.nio.fs=ALL-UNNAMED",
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
"-Dfile.encoding=UTF-8",
"-DwatchParentProcess=${watch_parent_process}",
"-noverify",
"-XX:+UseParallelGC",
"-XX:GCTimeRatio=4",
"-XX:AdaptiveSizePolicyWeight=90",
"-Dsun.zip.disableMemoryMapping=true",
"-Xmx1G",
"-Xms100m",
"-jar",
"${serverdir}/plugins/org.eclipse.equinox.launcher_${launcher_version}.jar",
"-configuration",
"${serverdir}/config_${jdtls_platform}",
"-data",
"${datadir}"
]
/usr/lib/jvm/java-11-openjdk-amd64/bin/java --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dfile.encoding=UTF-8 -DwatchParentProcess=true -noverify -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -jar "/home/bani/.cache/sublime-text/Package Storage/LSP-jdtls/server/1.12.0-202206011637/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar" -configuration "/home/bani/.cache/sublime-text/Package Storage/LSP-jdtls/server/1.12.0-202206011637/config_linux" -data "/home/bani/.cache/sublime-text/Package Storage/LSP-jdtls/data"
source.java
source.java
{
"bundles": [
"${debug_plugin_path}"
]
}
{
"java": {
"autobuild": {
"enabled": true
},
"codeGeneration": {
"generateComments": false,
"hashCodeEquals": {
"useInstanceof": false,
"useJava7Objects": false
},
"toString": {
"codeStyle": "STRING_CONCATENATION",
"limitElements": 0,
"listArrayContents": true,
"skipNullValues": false,
"template": "\\${object.className} [\\${member.name()}=\\${member.value}, \\${otherMembers}]"
},
"useBlocks": false
},
"completion": {
"enabled": true,
"favoriteStaticMembers": [
"org.junit.Assert.*",
"org.junit.Assume.*",
"org.junit.jupiter.api.Assertions.*",
"org.junit.jupiter.api.Assumptions.*",
"org.junit.jupiter.api.DynamicContainer.*",
"org.junit.jupiter.api.DynamicTest.*",
"org.mockito.Mockito.*",
"org.mockito.ArgumentMatchers.*",
"org.mockito.Answers.*"
],
"filteredTypes": [
"java.awt.*",
"com.sun.*"
],
"guessMethodArguments": false,
"importOrder": [
"java",
"javax",
"com",
"org"
],
"maxResults": 0,
"overwrite": true
},
"configuration": {
"checkProjectSettingsExclusions": true,
"maven": {
"globalSettings": null,
"userSettings": null
},
"runtimes": [],
"updateBuildConfiguration": "interactive"
},
"contentProvider": {
"preferred": null
},
"errors": {
"incompleteClasspath": {
"severity": "warning"
}
},
"foldingRange": {
"enabled": false
},
"format": {
"comments": {
"enabled": true
},
"enabled": true,
"onType": {
"enabled": false
},
"settings": {
"profile": null,
"url": null
}
},
"home": "/usr/lib/jvm/java-11-openjdk-amd64",
"implementationsCodeLens": {
"enabled": true
},
"import": {
"exclusions": [
"**/node_modules/**",
"**/.metadata/**",
"**/archetype-resources/**",
"**/META-INF/maven/**"
],
"gradle": {
"arguments": null,
"enabled": true,
"home": null,
"java": {
"home": null
},
"jvmArguments": null,
"offline": {
"enabled": false
},
"user": {
"home": null
},
"version": null,
"wrapper": {
"enabled": true
}
},
"maven": {
"enabled": true
}
},
"imports": {
"gradle": {
"wrapper": {
"checksums": []
}
}
},
"maven": {
"downloadSources": false,
"updateSnapshots": false
},
"maxConcurrentBuilds": 1,
"progressReports": {
"enabled": true
},
"project": {
"importHint": true,
"importOnFirstTimeStartup": "interactive",
"referencedLibraries": [
"lib/**/*.jar"
],
"resourceFilters": [
"node_modules",
".git"
]
},
"refactor": {
"renameFromFileExplorer": "prompt"
},
"references": {
"includeAccessors": true
},
"referencesCodeLens": {
"enabled": true
},
"saveActions": {
"organizeImports": false
},
"selectionRange": {
"enabled": true
},
"semanticHighlighting": {
"enabled": false
},
"server": {
"launchMode": "Hybrid"
},
"showBuildStatusOnStart": {
"enabled": false
},
"signatureHelp": {
"enabled": true
},
"sources": {
"organizeImports": {
"starThreshold": 99,
"staticStarThreshold": 99
}
},
"templates": {
"fileHeader": [],
"typeComment": []
},
"trace": {
"server": "off"
}
},
"jdtls": {
"enableLombok": false
}
}
{}
/home/bani/AndroidStudioProjects/SublimeTest1/app/src/main/java/com/example/sublimetest1/MainActivity.java
{
"auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
"lsp_active": true,
"syntax": "Packages/Java/Java.sublime-syntax"
}
source.java
[
"/home/bani/AndroidStudioProjects/SublimeTest1"
]
{
"completion_insert_mode": "replace",
"show_diagnostics_panel_on_save": 1
}
the completion didn't work, cant recognize any android api. do i have to modify the gradle.home and gradle.java.home in settings? if yes, how? whats the differences between those two?
Notes: the project tested was Empty Activity template from android studio.
@BanDroid You need at least Java 17 for jdtls. Your issue may be unrelated to Android.
@BanDroid You need at least Java 17 for jdtls. Your issue is unrelated to Android.
Sorry, but my java (console) projects working fine, getting all reference, completion, diagnostic, etc.
But when it comes to android project, it didn't work (cannot recognize any android classes) but class from java still works, and also giving error of MainActivity is not in the classpath.
@BanDroid You need at least Java 17 for jdtls. Your issue is unrelated to Android.
Sorry, but my java (console) projects working fine, getting all reference, completion, diagnostic, etc.
But when it comes to android project, it didn't work (cannot recognize any android classes) but class from java still works, and also giving error of MainActivity is not in the classpath.
Can you share a project where the issue occurs?
Can you share a project where the issue occurs?
It just Empty Activity from android studio.
Here's how i'm testing it out:
Try setting "java.jdt.ls.androidSupport.enabled": true
in the jdtls preferences:
// This is LSP-jdtls.sublime-settings
{
"settings": {
"java.jdt.ls.androidSupport.enabled": true
},
}
Try setting
"java.jdt.ls.androidSupport.enabled": true
in the jdtls preferences:// This is LSP-jdtls.sublime-settings { "settings": { "java.jdt.ls.androidSupport.enabled": true }, }
Sorry, still the same. LSP still running fine but cant recognize any android classes.
There's also error of MainActivity.java is not on the classpath of project app, only syntax errors are reported, jdtls, Line 1, Column 1
It seems the file app/.classpath is the functionality of this plugin for the project to work. Let me know if there's something to do with that.
@BanDroid that error usually happens if the workspace ist not set correctly. Please make sure, that the first folder in your sidebar is the project base folder.
With that I was able to import your demo project and get completion, docs,...
The sidebar should look like this:
@BanDroid that error usually happens if the workspace ist not set correctly. Please make sure, that the first folder in your sidebar is the project base folder.
With that I was able to import your demo project and get completion, docs,...
As you could see in my troubleshoot result in the Project/Workspaces, i only open 1 project and it is the root path of the project
Please double-check all of these points:
java.jdt.ls.androidSupport.enabled
. You can also try the latest main (by cloning the repo), I pushed the setting yesterday../gradlew assembleDebug
finishes without issuesWith that, it works on my system (I know that that does not help - but it makes it hard for me to reproduce). If even that does not work, enable LSP log in the LSP settings and provide a server log together with a new Troubleshoot Server
.
Already tried, still the same (jdtls run fine and could give completion from project reference but cant recognize any android classes). i will try with openjdk-17 next time, and will give you information here.
I still getting the same result, already use openjdk-17, my JAVA_HOME
already pointing to it and my java path in jdtls settings already changed to my openjdk-17.
please checkout these log from toggle panel and also the new troubleshoot i did.
i also using the debug version of this plugin as you said (by cloning it)
Your logs do not look like they are taken from the latest main. Let's eliminate all external factors:
~/.cache/sublime-text/Package\ Storage/LSP-jdtls
subl --safe-mode
https://github.com/sublimelsp/LSP-jdtls
into that folderMainActivity.java
Then code intelligence should work. To test that, you can hover on AppCompatActivity
.
the server is work in android project now. unfortunately, still give a weird error.
/home/bani/AndroidStudioProjects/SublimeTest1/app/src/main/java/com/example/sublimetest1/MainActivity.java:
1:1 error The type java.lang.invoke.LambdaMetafactory cannot be resolved. It is indirectly referenced from required .class files Java:16777540
@BanDroid These are upstream issues of JDTLS, because they occur in VSCode too. You can open a new issue here: https://github.com/eclipse/eclipse.jdt.ls/issues
It said that JDTLS https://github.com/eclipse/eclipse.jdt.ls has experimental Android support.
I've already set settings for Gradle support but when I tried to open Android project , Android completion is likely doesn't work. It downloaded several deps into GRADLE_USER_HOME but again completion is not working.
I know this is still experimental, but does ANdroid support requires different settings mainly on
"language.java.languageServer.arguments"
part , or somewhere?