Joshua's Docs - Android Studio IDE - Notes
Light

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 or CMD + P in VSCode)?
    • To search for just files, use the Find file command, which is CTRL + SHIFT + N (or CMD + SHIFT + O on Mac)
    • Press SHIFT twice to bring up comprehensive search (Search everything)

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:

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
    1. Navigate to: Settings -> Editor -> Code Style -> XML -> Code Generation
    2. Uncheck both boxes (___ comment at first column), although technically only the line comment should be necessary to uncheck, if you only care about single-line comments
  • 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.

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
Markdown Source Last Updated:
Sat May 15 2021 19:46:56 GMT+0000 (Coordinated Universal Time)
Markdown Source Created:
Sat May 15 2021 19:41:32 GMT+0000 (Coordinated Universal Time)
© 2024 Joshua Tzucker, Built with Gatsby
Feedback