Java Intellisense - adelphes/android-dev-ext GitHub Wiki
Android for VSCode supports Intellisense for Java source files.
By default, the Android extension for VSCode enables context-sensitive code-completion using data gathered from the Android framework library. This library contains all public classes, fields and methods for Android Platform APIs.
Jetpack + AndroidX
Modern apps frequently make use of AndroidX modularised libraries (otherwise referred to as Android Jetpack) - these libraries are not enabled by default in VSCode code-completion, but can be configured by the developer.
To include androidx.*
types in Java Intellisense, the relevant androidx
library must be added to the workspace settings:
- In VSCode, use the command palette to select Preferences: Open Workspace Settings (JSON).
- In the JSON file, add a android-dev-ext.codeCompletionLibraries section as shown below:
// .vscode/settings.json
// Place your settings in this file to overwrite default and user settings.
{
"android-dev-ext.codeCompletionLibraries": [
"androidx.activity:activity",
"androidx.core:core",
"androidx.fragment:fragment",
"androidx.navigation:navigation-fragment",
]
}
- For each
androidx
library used in your application, include the corresponding library in the list. In the example above, several androidx libraries relating to activities, fragments and navigation are included. - The settings JSON file itself supports code-completion - use
ctrl/cmd
-space
to display a list of supported androidx libraries. - Save the file and the androidx types will be included in the code-completion options.