When developing Cardboard apps for Android, there's tons of stuff that you need to track, including all your files and folders, Java classes and objects, and functions and variables. You need a properly organized Java program structure and valid language syntax. You need to set options and manage processes to build and debug your applications. Whew!
Thank goodness we have Android Studio, a powerful IDE (integrated development environment). It's built on top of IntelliJ IDEA by JetBrains, a popular intelligent Java development suite of tools.
It's intelligent because it actually gives you relevant suggestions as you write your code (Ctrl + Space), helps navigate between related references and files (Ctrl + B, Alt + F7) as well as automates refactor operations, such as renaming a class or method (Alt + Enter). In some ways, it may know what you're trying to do, even if you don't. How smart is that?
If you don't already have Android Studio installed on your development machine, what are you waiting for? Head on over to the Android developers page (http://developer.android.com/develop/index.html) and download it to your system. It's available for Windows, Mac OS X, or Linux. You can install the full Android Studio package and not just the SDK tools. Then, obediently follow the installation instructions.
There's a lot to Android Studio. In most cases, we'll just explain with the help of examples as we go along. But let's take a little time to review a few features, especially the ones that are relevant to Cardboard development. Just make sure that you read the documentation available at the Android developer tools page if needed (http://developer.android.com/tools/studio/index.html).
For a beginner, the Android Studio user interface can seem daunting. And the default interface is only the beginning; editor themes and layouts can be customized to your liking. Worse, it has a tendency to change with new releases, so tutorials can seem out of date. While this can make it challenging for you to find what you need on a particular occasion, the underlying functionality does not change a whole lot. An Android app is an Android app is an Android app, in most cases. We used Android Studio 2.1 for Windows for this book (although some screen captures are from an earlier version, the interface is essentially identical).
Let's take a brief tour of the Android Studio window, as shown in the following screenshot:
The menus of Android Studio are:
Notice the select menu on the top left-hand side of the hierarchy pane. In the preceding screenshot, it is set to Android, which just shows the Android-specific files. There are other views that might also be useful, such as Project, which shows all the files and subdirectories under your project root directory, as mentioned earlier.
It will be helpful for you to pay attention to the Debuggable Application drop-down menu, Log Level and other filters within logcat in order to filter out the "log spam" that will make it hard for you to find the output that you are looking for. Also, note that even on a high-end computer with a fast CPU, this log view can slow down Android Studio to a crawl. It is recommended that you hide this view when not in use, especially if you have multiple instances of Android Studio open.
It can be fun to poke around and browse all the different things Android Studio provides. To learn more, click on the Help | Help Topics menu items (or the ? icon on the toolbar) to open the IntelliJ IDEA help documentation (https://www.jetbrains.com/idea/help/intellij-idea.html).
Keep in mind that Android Studio is built on top of the IntelliJ IDE, which can be used for more than just the Android development. So, there's a lot here; some of which you'll never use; others you'll need but might have to hunt for.
Here's a bit of advice: with great power comes great responsibility (where have I heard this before?). Actually, with so many user interface things, a little tunnel vision will come in handy (yeah, I just made that one up). Focus on the ones you need to use when you need to use them, and don't sweat the other details.
Before we move on, let's take a glance at the main menu bar. It looks like the following screenshot:
Reading from left to right, the menu items are organized somewhat parallel to your application development process itself: create, edit, refactor, build, debug, and manage.
git
) commandsThere now, was that so scary?
If you haven't already, you might want to try and build the Cardboard Android demo app available from the Google Developers website's Android SDK Getting Started page (refer to https://developers.google.com/cardboard/android/get-started).
At the time of writing this book, the demo app is called Treasure Hunt, and there are instructions on how to clone the project from its GitHub repository. Just clone it, open it in Android Studio, then click on the green play button to build it, and run it. The rest of the Getting Started page walks you through the code that explains the key elements.
Cool! In the next chapter, we will start and rebuild pretty much the same project but from scratch.