Android Studio Overview
A free video tutorial from Rob Percival
Web Developer And Teacher
4.5 instructor rating • 40 courses • 2,048,340 students
Learn more from the full courseThe Complete Android N Developer Course
Learn Android App Development with Android 7 Nougat by building real apps including Uber, Whatsapp and Instagram!
31:59:24 of on-demand video • Updated August 2021
- Make pretty much any Android app you like (your only limit is your imagination)
- Submit your apps to Google Play and generate revenue with Google Pay and Google Ads
- Become a professional app developer, take freelance gigs and work from anywhere in the world
- Bored with the same old, same old? Apply for a new job in a software company as an Android developer
English [Auto] All right, so now you've got Android studio installed and set up, we're going to dive right in and create our first Android project once we've done that. We'll take a few minutes to familiarize ourselves with the Android studio interface and we'll run our default project on an Android phone simulator right here in our computer as well. So lots to cover. Let's get started. When you launch Android studio, you'll see a menu much like this, which is pretty straightforward. We're going to be selecting the top option, start a new Android studio project. So click that one and then you'll see a page like this with just a few settings for your new project or app. So I'm going to call the application demo app. I suggest you do the same. If you've not used Android today before, your company domain will probably be blank or you may have a suggested one in there. So I've got a personal example, dotcom here. It really doesn't matter too much what your company domain is at this point. I would recommend going for either your name or your company name if you've got one dotcom. And the only real importance of the company domain here is that the package name will be created from that company domain. So you can see it's created the package name as com dot Rob Percival dot demo app. So it's just the company domain in reverse and then the application name with any spaces or capitals or strange characters removed. The package name is used. If you're submitting your app to Google, play the unique way of referencing your app. So it has to be completely unique, but you can change it at any time. So if you do discover that someone else has already used a package name that you've created, you can change it later on. So don't worry too much about this. And then finally, we've got the project location so you can see it. But the app for me in the default location, Android studio projects, I'm just going to leave it there. But if you want to change it, then you can put it in any folder you like just by clicking the three dots then. OK, so far so good. Click next. Now we have a fairly big decision to make the minimum SDK that our app will support. You can see we've got all the various options right up to Android seven there and we can choose any one of those. But if you choose. Android seven, then your app will only be able to be run on phones running Android seven, which is, as you can see at the time of recording, not that many. You will, however, be able to use all specific features for Android seven. So my advice, what we're making basic projects is to stick with the default. So API 15 ice cream sandwich, which will run on ninety seven point four percent of devices and will likely include the vast majority of features that you'll need for your app. So we'll choose this one by default and we'll just switch to different versions of the API as and when we're using specific features. Feel free to use a different version if you want them down here, we can choose to support other Android platforms. We'll be looking at where later on, but we won't be looking at TV, auto or glass in this cause. So let's click next to continue. And now we're given the option to add an activity to our app. Now an activity, an android is essentially a screen. And you can see there are several different activities that we can add if we want to. So we've got a basic activity there with just a back button, a menu and a plus. And then we've got an empty activity which is selected by default and then some various other ones which will be looking at later on in the course, which are all fairly self-explanatory. We'll start with the empty activity. So select that one and click next. And then we can if we want to customize the name of that activity. But the default name main activity is one that you'll see over and over again when developing for Android. So we'll leave that as the default. OK, finally, we've got through all of the settings, so just click finish and it'll take a few moments, but Android will then create your project. And here we go, you'll be presented with a tip of the day if you haven't already turned those off for free, to leave those on there often quite useful, but I'll just switch that off and close that window. And this then is the main Android studio window. And this is where we'll be working for the majority of this course. Looks pretty empty at the moment. So let's bring in our project by clicking number one project at the top left there. So here you can see we've got two options to choose from. The first is our app. And you can see by the little folder symbol that this is the selection of folders and files that make up our app. The second is Gradle scripts. Now, Gradle is an open source build tool, which essentially is what Android studio uses to build your app from these folders and files. If we want to, we can add in some scripts to do some custom work in the build process. We'll be doing that later on in the course. But we don't need to do anything with gradle scripts right now. For now, though, we'll look into the app folder by clicking the triangle and you can see we've got three folders within that. So the first is manifests and in the manifest file we've got a single file, which is Android Manifest Dot XML. If we have a quick look at that, we don't need to worry too much about the code or we need at this point is to know that the Android manifest contains some basic details about our app, such as the icon label. So the app name there, the app theme, et cetera, will be editing this later on. But for now, we'll just leave it as the default. At the bottom there, we've got our Reza Fulda short for resources, and this is where we'll be putting things like icons, images that we'll use in our app or music that our app needs. Finally, then the middle folder, Java is where the real meat of our app lies. And specifically, we're going to ignore the two test folders for the moment and. In that first folder, comprehensive demo app will click on main activity, and this is the main file where code for our app is run. So this is your first taste of Java and it looks quite scary. But don't worry, it'll be second nature in just a few days time. We'll have a quick summary of what's going on here. Essentially, we're defining the package, which is just a comprehensive demo app. Then if we click on the three dots here, you can see we're importing two classes or essentially bundles of code that will allow our app to work, will be importing many more classes later on, of course. But for now, we've just got the default to the first is app compact activity competition for compatibility. And essentially this makes sure that our app is backward, compatible with as many older versions of Android as possible. And then we've just got the operating system bundle, which allows us to work with the Android operating system. And then finally here, we're creating a class called Main Activity, which will allow us to work with the activity that we created to remember the screen will display to users. Now, I'm not going to go into this code in more detail right now, but we will be covering it extensively later on. So don't worry about that. For now, though, we're going to go back to Rez and look in the layout folder and you should see activity underscore main dot, XML, the double click on that. And this is where we'll see what our app actually looks like. And there it is. It looks slightly horrendously complicated. But again, don't worry, we'll break it down in no time at all. So this XML file is what defines the layout and the look of our activity or the screen that we present to users. So obviously in the middle, we've got our phone and we'll get a preview there of what our app looks like on the left hand side of this window. We've got various user interface elements that we can drag into our app. So we've got some layouts. You get a guide from the little icon as to what they might do. And we'll be looking at all of these layouts later on in the course. And then we've got what are known as widgets. So things like text views to allow us to display text buttons, radio buttons, checkboxes switches. You get the idea, purkiss bars. Then underneath that, we've got text fields, which we can use to get the user to enter some information. We've got containers for things like lists or videos, and then we've got various date and time features, so a date picker and a clock. And then we've got some advanced user interface elements like Zoom controls will be looking at some of these later on and some custom widgets as well if we want to build a completely customized user interface. So we'll be looking at those in more detail later on. For now, let's just run on and look at this top bar here so we can quite easily switch to different devices. So if I wanted to have a more tablet sized device, I could switch to a Nexus 10 and this would give me a preview of what my app would look like on a tablet. And I could also switch to portray it in landscape mode very easily. I can even change the app theme. Right there, you can see there's many different things to choose from. I'm going to leave it as the default for now. I can switch activities if I want to. The moment I've only got the one, so I'll just leave it as that. If we've introduced Translation's, then we can edit those using the world symbol and we can also change the version of Android that we're previewing with as well. So there's a lot we can do just from this screen and then we've got some zoom options we can refresh and there's some more settings. Hidden behind the Coquille there as well. Now we're almost done with our preview, just need to look at the component tree up here on the top, right. This is a way of looking at all the different elements that make up your activity or your screen for the user. So the top level, we've got the device screen itself. And then within that we've got a relative layout, which essentially means that everything is laid out relative to what's around it. So if I was to add a second TextView beneath the tiny hello world one there, it would be displayed relative to the first one. We'll see how that works in more detail in the next video. But our final user interface element there is the TextView itself, which if I zoom in. You know, if you can see says hello, world, and finally then at the bottom, we've got properties which will vary depending on what element you've got selected at any given time and has a huge range of properties that we can use to customize each individual element. Again, we'll look at those in much more detail when we look at the specific user interface element types in this section. But that's essentially it. We've met the two main files that we're going to be working with. That is the main activity, the XML file, which controls the layout and the main activity Java file, which controls what the app actually does later on. We'll also be looking at editing the manifest and the gradle scripts. But for now, those two files are really the ones you should be concentrating on. All right. So our final thing then for this video is to actually see our demo app in action. And we do that by clicking the green play button at the top there. And this will allow us to run our app either on an emulator within our computer or on a Android device attached to our computer by USB. So we're going to go for the emulator here and I haven't set up any yet. So I'm going to click create new emulator. And now you can choose between a huge range of different devices. That's the list of phones. We can use tablets from where and TV devices as well. I'm going to go for the Nexus s simply because the resolution works out well for my screen. But you can choose any one of these devices. Really doesn't matter. Then click next and then we can choose which version of Android our device will run. And you can see we've got a range of options here from gingerbread to marshmallow. You'll notice that some of them have got an underscore 64 at the end. This is because they're 64 bit. None of our projects particularly use 64 bit architecture. So it doesn't matter which one you choose. But I would recommend choosing one with Google APIs built in. This will make things like integrating Google Maps and Google Play much more straightforward. Unfortunately, at the time of recording this video, there isn't a version of Nugget with Google APIs built in. So I'm going to stick with the recommended option of API level 22 and again will switch to a different version as and when we need to. But you can choose whichever version you like. I would recommend one with Google APIs and then we'll click next and you can change again the device name, the Android version and the scale default orientation. You can bring in some hardware optimization on the emulated performance if you want, but I'd leave that as automatic. The device frame is just that little bit of a phone like what we saw earlier on in the app preview. I think that looks quite nice, so I'm going to leave it there. But you can disable it if you want to. OK, so then click finish, and that will then create your AVD or Android virtual device and. I would select use the same selection for future launches just makes it a little bit quicker, saves you having to select it every time and then click, OK. And this will then launch your AVD and run your app within it. It will probably take about half a minute or so depending on your machine. One advantage of Android Studio two over the previous version is that the emulators do run a lot faster. And here we are. Here's my device. So it's currently launching. You can see we've got a nice set of options down the right here. We can change the orientation. We can take a screenshot. We can change the volume. And we can press the defo Android buttons there as well if we want to. But there we go. You hopefully saw the Android home screen there. But here is our app takes a little while to readjust to the orientation change. Let's put it back up. The right way and there we go. So congratulations, you've run your first Android app in the emulator and it does indeed look reasonably like was predicted. In the preview that we saw down there, one final thing to notice is that down at the bottom here, we've got loads and loads of logs or information about things that have happened without app. This is a very useful area to be getting into when we start building apps and looking for errors or making sure that our apps are running as we think they are. But for now, really, it just tells us that our app is up and running. So there we go. That's your whirlwind introduction to Android studio. Hopefully you now feel reasonably comfortable with how the software works and in particular, the relationship between these two core files, the XML layout file and the main activity Java code in the next few videos will be focusing on the app layout and will be adding some different widgets to our apps and then customizing them, starting with the TextView in the next video. So you there?