Trying to get vscode to detect Android Project but it does not seem to work. With java.jdt.ls.androidSupport.enabled set to on it should automatically detect Android Project, add necessary files and classpath in Project and External Dependencies automatically but after many attempts none of the solutions seem to work.
Android support should be available from here (https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/2197) . This introduces a init.gradle file that should automatically add the Android Sourcesets, add classpath, all other android dependencies but I do not think that ever runs.
Here are my steps and partial temporary solution I came up with.
Steps:
Create a new Android Project using Android Studio using Java and Groovy Gradle.
Move over to vscode. Install the plugin pack, enable vscode setting java.jdt.ls.androidSupport.enabled to on. (I have all other necessary setups such as having jdk installed.)
After that by default vscode setting java.import.gradle.enabled is set to enable so it detects the gradle projects. So far the error in MainActivity.java is not on the classpath of project app.
Using Add Folder to Java Source Path do not work as it says Unsupported operation. Please use build.gradle file to manage the source directories of gradle project. To resolve it I added this to app/build.gradle file:
Now it fails to get definitions for android and androidx. Errors: The import android cannot be resolved and The import androidx cannot be resolved. Still nothing inside Project and External Dependencies even after running gradle build.
It gives definions for android imports such as import android.os.Bundle; but now the problem is The import androidx.appcompat cannot be resolved .
I am looking for a solution that either gives me type definions for androidx.appcompat and other necessary dependencies. Or ways to get the plugin to detect and configure Android Project automatically. Or way to manually run the init.gradle file.
Trying to get vscode to detect Android Project but it does not seem to work. With
java.jdt.ls.androidSupport.enabled
set toon
it should automatically detect Android Project, add necessary files and classpath inProject and External Dependencies
automatically but after many attempts none of the solutions seem to work. Android support should be available from here (https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/2197) . This introduces a init.gradle file that should automatically add the Android Sourcesets, add classpath, all other android dependencies but I do not think that ever runs.Here are my steps and partial temporary solution I came up with.
Steps:
java.jdt.ls.androidSupport.enabled
toon
. (I have all other necessary setups such as having jdk installed.)java.import.gradle.enabled
is set to enable so it detects the gradle projects. So far the error inMainActivity.java is not on the classpath of project app
.Add Folder to Java Source Path
do not work as it saysUnsupported operation. Please use build.gradle file to manage the source directories of gradle project.
To resolve it I added this toapp/build.gradle
file:android
andandroidx
. Errors:The import android cannot be resolved
andThe import androidx cannot be resolved
. Still nothing insideProject and External Dependencies
even after running gradle build.It gives definions for android imports such as
import android.os.Bundle;
but now the problem isThe import androidx.appcompat cannot be resolved
.I am looking for a solution that either gives me type definions for
androidx.appcompat
and other necessary dependencies. Or ways to get the plugin to detect and configure Android Project automatically. Or way to manually run the init.gradle file.