Project Structure and File Types
https://developer.android.com/studio/projects#ProjectFiles
🚨 WARNING: Coming from an IDE like VSCode, Android Studio can feel like a totally different world, and it has some design decisions that are jarring and might catch you off guard.
Coming from VSCode - Where is?...
See Keyboard Shortcuts for exhaustive list of current keyboard shortcuts
- Where is the command palette equivalent (
CTRL + SHIFT + P
in VSCode)?- Doesn't really exist?
- Pressing
shift
twice will bring up the "search everything" console, which is helpful
- Where is the Go to File... equivalent (
CTRL + P
orCMD + P
in VSCode)?- To search for just files, use the
Find file
command, which isCTRL + SHIFT + N
(orCMD + SHIFT + O
on Mac) - Press
SHIFT
twice to bring up comprehensive search (Search everything
)
- To search for just files, use the
File Sidebar
File Sidebar - Show Real Locations
As someone used to VSCode as an IDE, and in general having IDE's showing the real locations of files in explorer views, this caught me completely off-guard at first (emphasis mine):
By default, Android Studio displays your project files in the Android view. This view does not reflect the actual file hierarchy on disk, but is organized by modules and file types to simplify navigation between key source files of your project, hiding certain files or directories that are not commonly used.
   - Android Docs: Project Files
To force it to show the actual real file locations, select Project
from the view dropdown in the left hand explorer panel.
File Sidebar - Highlight Current File
Another (annoying) difference between most IDEs and Android Studio, is that Android Studio by default does not highlight the currently open file in the sidebar.
You can either:
- Older versions of Android Studio: Project view settings -> Turn on
Autoscroll from Source
as an option - Newer versions of Android Studio: Project view settings ->
Always select opened file
Running on a Real Device
See "Run Apps on a Hardware Device".
If your phone does not show, despite being connected, having granted permission to the host OS, and having debugging enabled - make sure you actually have ADB installed, and in your PATH. Try running through the Connection Troubleshooter.
If you were missing it from your PATH, add it, and then:
- Completely restart Android Studio (close all windows, and re-open)
- Reconnect your phone
- Restart any consoles that are trying to use ADB
Troubleshooting
- It places comments at the wrong indentation level in XML files
- Navigate to:
Settings -> Editor -> Code Style -> XML -> Code Generation
- Uncheck both boxes (
___ comment at first column
), although technically only theline comment
should be necessary to uncheck, if you only care about single-line comments
- Navigate to:
- When I click "finish" in a file creation prompt (e.g. to make a new activity), nothing happens?!
- Do you have unsaved changes to your main
AndroidManifest.xml
? Studio will refuse to save the new file if the manifest is in a "bad" state, and it is unsure of how to modify it safely.
- Do you have unsaved changes to your main
Random Q&As
- How to scaffold
.gitignore
, quick-start git integration?Menu -> VCS -> Enable Version Control Integration
, then follow prompt- You can add the
.idea
folder, since the default root.gitignore
, as well as/.idea/.gitignore
should exclude hyper-local files such as/.idea/workspace.xml