Android Studio Overview

Rob Percival
A free video tutorial from Rob Percival
Web Developer And Teacher
4.5 instructor rating • 41 courses • 1,841,847 students

Learn more from the full course

The Complete Android N Developer Course

Learn Android App Development with Android 7 Nougat by building real apps including Uber, Whatsapp and Instagram!

31:59:41 of on-demand video • Updated February 2019

  • 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 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 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 you gave before your company domain will probably be blank or you may have a suggested one in there. So I've got Rob Percival dog example dot com 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 dot com 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 say it's created the package name as Colma dot Roper's of 0.10 or 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 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. You can say it's put 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 3.10. OK. So far so good. Click next. Now we have a fairly big decision to make the minimum SDK that our app will support and you can see we've got all the various options right up to Android 7 there and we can choose any one of those. But if you choose Android 7 then your app will only be able to be run on phones running Android 7 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 7. So my advice are we're making basic projects is to stick with the default 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 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. 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 course 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 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 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 it off. Feel free to leave those on there are often quite useful but I'll just switch that off and close that window and this then is the main Andrew's studio window and this is where we'll be working with 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 graded scripts. How grateful 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 graded scripts right now. For now though we'll look into the app folder by clicking the triangle and you can see we've got 3 folders within that. So the first is manifests and in the manifest file we've got a single file which is Android manifest on SML if we have a quick look at that. We don't need to worry too much about the code. All we need at this point is to know that the Android manifest contains some basic details about OB such as the icon label. So the app name then the app name etc. we'll be editing this later on but for now we'll just leave it as the default at the bottom that we've got our rez folder 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 OP needs. Finally then the middle fold at 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 where Percival that 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 years time we'll have a quick summary of what's going on here. Essentially we're defining the package which is just the calm run Percival that there are app then if we click on the 3.10 you can see we're importing two classes or essentially bundles of code that will allow app to work. We'll be importing many more classes later on the course but for now we've just got the default to the first is app compact activity compatible for compatibility. And essentially this makes sure that our app is backwardly 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 get back to rez and look in the layout folder and you should see activity underscore main dot SML doubleclick on maps. 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 SML 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 get a preview 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 display text buttons radio buttons checkboxes switches. You get the idea Perkis 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 data and time features. So a date picker and a clock and then we've got some advanced user interface elements like zoom controls we'll 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 here so we can quite easily switch to different devices. So if I wanted to have a more tablet size 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 write them you can see there's many different themes 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 got the one so I'll just leave it as that. If we've introduced translations 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 the screen and then we've got some zoom options we can refresh and there's some more settings hidden behind the cogwheel 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 at the top level we've got the device screen itself and then within that we've got a relative lay out which essentially means that everything is laid out relative to what's around it. So if I was to add a second text textfield beneath the tiny hello world one then 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 that is the text view 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 the 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 SML 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 grateful scripts. But for now those two files are really the ones you should be concentrating on her rights. 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 your ISP. 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 service the phones we can use tablets from when 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. It really doesn't matter. Then click next. And then we can choose which version of Android device will run. You can see we've got a range of options here from ginger bread to marshmallow. You'll notice that some of them have got an underscore Sixty-Four the end. This is because there are 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 API is 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 API is built in. So I'm going to stick with the recommended option of API level 22. And again we'll switch to a different version ASM when we need to. But you can choose whichever version you like. I would recommend one with Google API is and then will click next and you can change again the device name the Android version and the scale. The full 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. Then click Finish and that will then create your DVD or Android virtual device and I would select use the same selection for future launches. Just makes it a little bit quicker and saves you having to select it every time and then click OK. And this will then launch your avi 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 2 over the previous version is that the emulators do run a lot faster and are here's my device is 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 screen shot we can change the volume and we compress the full Android buttons there as well if we want to by there we get you we saw the Android homescreen them but here is an app takes a little while to adjust 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 doesn't 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 logos 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 SML layout file and the main activity Java code in the next few videos will be focusing on the layout and we'll be adding some different widgets to our apps and then customizing them starting with the text view in the next video. See them.