Introduction to Android Studio: A look around the IDE
Android Studio is the official Integrated Development Environment (IDE) for Android app development, based on IntelliJ IDEA.
The User Interface
- The toolbar lets you carry out a wide range of actions, including running your app and launching Android tools.
- The navigation bar helps you navigate through your project and open files for editing. It provides a more compact view of the structure visible in the Project tool window.
- The editor window is where you create and modify code. Depending on the current file type, this window can change. For example, when viewing a layout file, the editor window displays the layout editor and offers the option to view the corresponding XML file.
- Tool windows give you access to specific tasks like project management, search, version control, and more. You can expand them and collapse them.
- The status bar displays the status of your project and the IDE itself, as well as any warnings or messages.
Project Structure
All the build files are visible at the top level under Gradle Scripts and each app module contains the following folders:
- manifests: Contains the
AndroidManifest.xml
file. - java: Contains the Java source code files, including JUnit test code.
- res: Contains all non-code resources, such as XML layouts, UI strings, and bitmap images.
You can also customize the view of the project files to focus on specific aspects of your app development. For example, selecting the Project view, will display the files like how they look in your disk.
The views that are available in Android:
- Project
- Packages – displays a view of all the packages in the app (libraries as well).
- Scratches
- Android – the default view of a project with the essential app files displayed.
- Project Files
- Problems – displays links to the source files containing any recognized coding and syntax errors.
- Production – the files that are built into production
- Tests -test files generated in the app
- Android Instrumentation tests
XML View:
To edit XML, you have two options: the Design and Text view. You can edit the XML file directly in the Text view and simultaneously view the output or you can directly use the design view.
- The Palette section contains a list of elements that can be used in the XML. These include layouts, widgets, text fields, custom views and more that you can drag and directly drop into the Device view.
- The Component Tree section contains a view of all the components/elements in the XML with the parent-child view.
- The Properties section lists out all the properties of an element that can be dynamically edited.
- The Device Screen view shows the view of the design screen with the way the design may look in an Android device. You can select the type of mobile in the menu above the Device Screen along with the API level, orientation, theme and zoom.
Log messages
When you build and run your app with Android Studio, you can view adb output and device log messages (logcat) by clicking Android Monitor at the bottom of the window.
The LogCat is useful for monitoring your android device and in capturing error messages if your app crashes. The log will also help you locate in which class and at what line the error has occured. You can also use the log to monitor output by using Log.d() function.
Log.d("Tag", "Message");