Install Android Studio, and take a quick tour with a Hello World app. Find out where to learn more about developing apps with Android Studio.
- [Instructor] Android Studio is the most common platform for development of Android apps, and we'll be using it to demonstrate the use of security coding features and techniques. I'll briefly introduce Android Studio, and we'll run through the basic steps to get up and running with it. I'll also run through the basics of developing, and running, an Android app. I won't be providing an in-depth training course on Java development for Android, nor will I go into any more detail than I need to on the use of Android Studio. If you're not familiar with Android Studio, you may like to check out my colleague's essential training video.
Likewise, if you're new to developing Android apps, you may like to check out this course. We'll need to get our development environment set up before we can do Android app development. We can do that by loading Android Studio, the IDE we'll be using to develop Android apps. This is Google's official IDE for Android, and includes the Java SDK, the Android SDK, the native code SDK, and the range of virtual devices we need for development and testing. Android Studio can be installed from here.
Downloading and installing this takes some time, but is straightforward. Once Android Studio is installed, we'll need to start it up. If this is the first time its run, it will automatically install the Android SDK. We'll then need to load any APIs that we'll be using, and these represent the operating system levels for which we'll be developing. As security features have been introduced over time, we'll need to ensure that we're at the right level when using certain security features. Okay, I've got Android Studio loaded, so let's start it up.
Android Studio starts up with a list of previous projects and options to start a new project, open an existing one, or import a new one. Let's start a new one. I'll call it Hello World, and leave the Company domain, and Location, as they are. I'll take the minimum SDK default of API 15 for the moment. I'll start with an empty activity, and I'll keep the name Main Activity, and finish.
Android now creates the project, and displays the empty project in the IDE. Before we go any further, let's have a quick look at some of the basic IDE features. The IDE has a left, a middle, and a right pane. These panes can be displayed or removed by using the left and right-hand vertical tabs. There are also some tabs at the bottom which can be used to display, or undisplay lower panes. For instance, we can click on the bottom tab, saying Android Monitor, and a new pane will appear at the bottom, showing system activity, monitoring, and logging.
If we click it again, the pane will disappear. Similarly, clicking Terminal, will show a Windows Command show. Clicking again, will remove it. At the left, we can click the lower left tab Build Variants. And the Build Configuration will be shown. Clicking it again will remove the pane. If we click on the top right for Projects, the Project Pane will be removed. And clicking it again will recover it.
At the right, we can click the top and bottom tabs to display the Gradle and Android panes. The middle pane, as we would expect, contains the source for our Main Activity. Also at the left, we currently have a tab above the pane which is titled Android. If we click the drop-down, we have a number of other displays we can select. Above the panes, we have the Breadcrumb Trial, showing the trial from the Hello World project, to the app, to source, to main, and all the way down to Main Activity. This helps us see the context for the displayed source.
The middle panel has two tabs at the top: the activity_main.xml, and the MainActivity.java. If we select activity_main.xml, we'll see the layout view for the application. Let's add a text view in the middle of the screen. Android Studio defaults the text to Hello World. And we'll make it Material Medium. This sets the font of the display text.
While we're here, note the tab at the top, which indicates we're developing for a Nexus 4. Let's click the drop-down, and set that to a Nexus 5X. The IDE has an extensive menu system at the top, and key items have icons below the menu bar. I won't go through the menu in detail. We'll cover what we need when we use it during the course. One key one, though, is the Tools, Android selection. This allows to access important subsystems, such as the AVD Manager, and the SDK Manager.
Let's select SDK Manager. This is where we can load the various APIs that we may want to build for. You can see I have a number installed. You'll probably want to install API 15, API 21, and API 25, as a minimum. Let's take a look at the structure of the Android Studio app. The left-hand pane shows two entries: app, and Gradle Scripts.
Under app, we can see three entries: manifests, java, and res. Manifests contains the AndroidManifest.xml file. The java entry shows three entries for com.malcolmsure.helloworld. The top one is the main coding we can see in the middle pane. The next two are versions which include testing assertions, but we won't be using them here. Res contains the resources for the app, in particular the layouts and values. The values expand out to resources such as colors, strings, and styles.
So let's continue creating our Hello World program. We can see from the layout, that it's pretty much been done for us, and the MainActivity.java display, we can see that the only action in the app, is to display the layout. We can run the program, which will do a build for us. To do this, we'll use the green play button. This displays a target pane, in which we can select the target for our deployment. We'll create a new virtual device.
Now we can see the build is completed, the app has been deployed and run, and we can see the message Hello World. Down in the bowels of the Android Studio Project folder, we can see the APK that we've built. We'll be coming back to this APK to test it, as we progress through the course. That's a quick introduction to Android Studio, and to writing your first Hello World app for Android.
- Understanding Android OS, app, and hardware security components
- Using the Trusted Execution Environment
- Developing Android apps with security in mind
- Analyzing existing applications
- Understanding Android vulnerabilities
- Securing Android apps
- Developing secure enterprise apps