1.1 Introduction to the Editor

Starting an Android Studio Project

After you have successfully installed the Android Studio IDE, double-click the Android Studio application icon to start it. Click Start a new Android Studio project → then select “Empty Activity”. Name the project the same name that you want to use for the app.

Note: The company domain field must be unique if you wish to publish to Google Play, as that's the identifying name that differentiates your app from anyone else’s.

Editor Layout

The standard layout of the Android Studio editor has several logical panes that in all have all the functions you'll need to develop for Android.

The main five components of the editor that we'll touch upon includes toolbar, project pane, editor, menu bar, and bottom menu bar.

Toolbar

This is the bar near the top containing shortcuts to different actions within Android Studio. The most important is the green triangle allowing you to run your program. If you press it, you should see a simulator pop up and run the code.

Project Pane

Just as in most IDEs, our project files are available in the left third of the screen. You can navigate to different files in your project by using the project pane. One neat trick is to go to the toolbar at the top of the project pane and toggle from Project to Android; this way, you can navigate directly to the java and XML files.

Editor

This is the component of the screen where the code is written. If you just created a new activity, you should see something like this:

class MainActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    ...
  }
}

The code above might be a bit difficult to understand. For now, think of onCreate() method of MainActivity as the first method that is executed when running our application, similar to how public static void main(String[] args) is first executed in Java.

Bottom Menu Bar

The bottom menu bar returns output from the compiler and displays useful information about gradle and compile time errors. The bar also houses the debugger, which is a great tool to use for understanding errors.

Android Emulator

Android emulators are what developers use to test their application. A selection of available emulators shows up in the Toolbar, directly to the left of the green play button. Your connected Android devices will also show up here, which can also be used to test your application. To create a new Android Emulator, you must use Tools > AVD Manager to create and edit Android Virtual Devices.

Emulators are valuable tools for testing, but beware of the drawbacks. They will most likely be slower than their physical counterparts and will most definitely slow down your machine while you're running them. They often don't have as many capabilities as the real phone and certain functionality (like getting user location) is often absent. For applications that require user data, such as location or storage, it is recommended to test directly on a physical device.

Logcat

Android Studio doesn’t have a traditional version of the console that IDEs like Eclipse and PyCharm do. Instead, Android Studio uses what is referred to as Logcat. To open Logcat, navigate to View > Tool Windows > Logcat.

Our end users will never be interacting with Logcat, so this feature is only used by the developer for debugging purposes. Therefore, unlike Java’s standard System.out methods for printing to the console, Android Studio has it’s own conventions:

  • Log.d(tag, message) for logging debugging statements

  • Log.i(tag, message) for printing useful information to developers

  • Log.w(tag, message) for outputting a warning (generally for operations that should never occur)

  • Log.e(tag, message) for outputting an error message

Here's an example of how you might using the Logcat for debugging. In this example, we're printing out the string name to the console:

var name = "Android"
Log.d("tag_string", name)

Now, let’s look at the Logcat. If we re-run our project, we’ll see a huge stream of data that is completely independent of what we’ve told our program to print. You can filter out the stream by typing "tag_string" into the search bar and you should see the line:

<DATE> <TIME> <PID>-<TID>/com.example.myapplication I/tag_string:Android

Last updated