1 00:00:01,080 --> 00:00:06,030 All right, so in this video, we are going to set up our first project and we're going to look at the 2 00:00:06,030 --> 00:00:11,910 user interface and, for example, also change the text size of the code that we have. 3 00:00:12,450 --> 00:00:17,430 Okay, so the first thing that we see here is welcome to Android Studio, which is great, and then 4 00:00:17,430 --> 00:00:22,040 we can create a new project to start from scratch or we can open existing projects. 5 00:00:22,080 --> 00:00:29,150 So if you want to open, the project said, you will find as a downloadable file for lectures that you 6 00:00:29,370 --> 00:00:30,270 have in the course. 7 00:00:30,300 --> 00:00:31,740 And you can, of course, click on Open. 8 00:00:31,740 --> 00:00:33,570 But we're going to start with a new project here. 9 00:00:34,170 --> 00:00:41,220 So once you select that, you will find this screen here and the screen allows you to select from the 10 00:00:41,220 --> 00:00:42,690 different options that there are. 11 00:00:42,900 --> 00:00:47,550 So if you want to develop for a phone or a tablet, you would select the templates from here. 12 00:00:47,880 --> 00:00:52,680 So basically, you have a bunch of different templates that you can use in order to get started. 13 00:00:52,860 --> 00:00:58,440 And the beauty about those templates is that Android Studio is going to already give you a bunch of 14 00:00:58,440 --> 00:01:00,600 code that you don't have to manually, right? 15 00:01:00,610 --> 00:01:05,970 And that's really the power of using an integrated development environment such as Android Studio. 16 00:01:06,660 --> 00:01:12,060 So if you were to develop for the watch, you would use Wear OS or for Android TV, you would select 17 00:01:12,060 --> 00:01:12,720 something here. 18 00:01:13,020 --> 00:01:17,820 And the same goes for automotive, but the course is going to focus on phone and tablet. 19 00:01:18,120 --> 00:01:23,220 And you see by default and the empty activity is selected, so you can see that there are different 20 00:01:23,310 --> 00:01:31,320 types of activities that you can select from, and they will have different kinds of pre-defined code 21 00:01:31,770 --> 00:01:32,880 in them already. 22 00:01:33,480 --> 00:01:37,920 For example, if you want to navigate between different screens, you would use this bottom navigation 23 00:01:37,920 --> 00:01:38,700 activity. 24 00:01:39,090 --> 00:01:44,640 If you want to have this button here at the bottom right, where you click onto it in order to add something, 25 00:01:44,640 --> 00:01:46,260 you would use this basic activity. 26 00:01:46,470 --> 00:01:52,230 But we're going to start with this empty activity, which is going to be pretty clean and we can just 27 00:01:52,230 --> 00:01:53,550 build everything from scratch. 28 00:01:53,550 --> 00:01:58,290 And that makes sense for you as a beginner, especially because you need to understand how things are 29 00:01:58,290 --> 00:01:59,880 connected and how they are built up. 30 00:02:00,150 --> 00:02:06,090 So it doesn't make sense for you to have this bottom navigation activity where a bunch of code is already 31 00:02:06,090 --> 00:02:07,730 in there and you wouldn't understand it. 32 00:02:07,740 --> 00:02:09,930 So I think it makes sense to start here. 33 00:02:10,740 --> 00:02:14,820 Of course, you can also see that there are beautiful things such as AdMob ads activity where you have 34 00:02:14,820 --> 00:02:20,670 ads in there or the Google Maps activity, or even such a logging activity, which will definitely need 35 00:02:20,670 --> 00:02:22,140 in your developer's career. 36 00:02:22,350 --> 00:02:24,000 But let's start with this empty activity. 37 00:02:24,030 --> 00:02:29,470 So click next and then this screen pops up where you can create a new empty activity. 38 00:02:29,490 --> 00:02:36,360 You can, first of all, give your application a name, and I'm going to call this one my first app. 39 00:02:37,080 --> 00:02:39,390 OK, and then here the package name. 40 00:02:39,660 --> 00:02:44,610 It always consists of those three keywords separated by a comma. 41 00:02:44,700 --> 00:02:47,160 Usually that's come that example that my first step. 42 00:02:47,430 --> 00:02:51,750 So it's like you would go to a website, then it would be the other way around. 43 00:02:51,810 --> 00:02:54,870 It would say something like my first thought example dot com. 44 00:02:55,830 --> 00:03:04,170 So here you need to use a package name that will be unique to your own app, because once you want to 45 00:03:04,500 --> 00:03:08,760 release your application, it has to have a unique package name. 46 00:03:08,790 --> 00:03:14,400 Otherwise, the Android Play Store will not accept it, and you cannot publish the application. 47 00:03:14,730 --> 00:03:18,090 So here it really makes sense to have a package name that fits you. 48 00:03:18,090 --> 00:03:23,400 In my case, I'm going to use you, the Terriers, because my website is called Tartarus that you thought 49 00:03:23,520 --> 00:03:30,600 my first app and you could see everything is in lower capital letters than the safe location is basically 50 00:03:30,600 --> 00:03:33,480 where your project will be stored on your PC. 51 00:03:33,510 --> 00:03:38,910 You can change that any time by clicking on this button, and then you can select a different folder 52 00:03:38,910 --> 00:03:39,780 if you want to. 53 00:03:40,020 --> 00:03:41,520 I'm going to leave it at that. 54 00:03:42,150 --> 00:03:45,970 And then you have the language here so you can select Java or Kotlin. 55 00:03:45,990 --> 00:03:51,450 So this course is going to focus on Scotland entirely because what Google has said that they want to 56 00:03:51,450 --> 00:03:58,220 focus on Scotland when it comes to app development and they don't want to work with Java that much anymore. 57 00:03:58,230 --> 00:04:05,160 It has to do something with them running into some issues with Oracle, who own Java and so forth. 58 00:04:05,160 --> 00:04:07,170 So I'm not going to go too deep into that. 59 00:04:07,170 --> 00:04:13,020 But that's basically how they at one point decided to go with Kotlin, and we're going to use the latest 60 00:04:13,020 --> 00:04:14,200 and greatest, which is codling. 61 00:04:14,970 --> 00:04:17,519 Then you have the minimum SDK. 62 00:04:19,670 --> 00:04:25,520 And as the case stands for Software Development Kit, which is a collection of software development 63 00:04:25,520 --> 00:04:32,420 tools and one installable package, they facilitate the creation of applications by having a compiler 64 00:04:32,780 --> 00:04:36,080 debugger and even a software framework. 65 00:04:36,380 --> 00:04:41,720 There are normally specific to a hardware platform and operating system combination, so in this case, 66 00:04:42,080 --> 00:04:46,730 the SDK is specific to the Android apps that we're going to build. 67 00:04:47,540 --> 00:04:54,320 So here you can see that you have the API 21 with Android 5.0, which was called Lollipop. 68 00:04:54,440 --> 00:04:58,460 Back then, Android versions had a name that was somehow connected to a suite. 69 00:04:58,610 --> 00:05:02,180 You can see here Marshmallow Nougat, Oreo Pie, Jelly Bean. 70 00:05:02,600 --> 00:05:07,010 And at one point, they just called them like letter Q R s. 71 00:05:07,220 --> 00:05:11,300 So Android 12 is, of course, the latest version at the point of recording. 72 00:05:11,570 --> 00:05:16,580 But it doesn't mean that you should select Android 12 because if you do that and you want to specifically 73 00:05:16,580 --> 00:05:23,480 target phones that have Android 12 installed on them, you can see that this app will only run on one 74 00:05:23,480 --> 00:05:24,560 percent of devices. 75 00:05:25,250 --> 00:05:30,950 So that's not a good idea, even though it will contain all of the good and great features that Android 76 00:05:30,950 --> 00:05:32,120 12 has to offer. 77 00:05:32,420 --> 00:05:37,130 But it will be limited and will only run on devices that have Android 12 installed on them. 78 00:05:37,550 --> 00:05:42,710 And until it is a reasonable amount of devices, years will pass. 79 00:05:43,100 --> 00:05:48,710 So even if we take Android 10, you can see it's only installed on eight percent of devices, which 80 00:05:48,710 --> 00:05:55,610 is why, by default, it offers you API 21, which is running on ninety four point one percent of devices. 81 00:05:55,820 --> 00:05:58,760 And this is basically most people that have a phone. 82 00:05:59,030 --> 00:06:05,480 So if a phone uses an Android version that is older than 5.0, then probably it's not being used that 83 00:06:05,480 --> 00:06:06,170 much anymore. 84 00:06:07,720 --> 00:06:14,200 Now, the cool thing is that Google was smart enough to create things such as app compat, which is 85 00:06:14,500 --> 00:06:23,380 an app compatibility namespace that basically allows us to develop new features that will run on old 86 00:06:23,380 --> 00:06:24,030 devices. 87 00:06:24,100 --> 00:06:26,830 So they've really found a smart way around it. 88 00:06:27,100 --> 00:06:34,300 So basically, you can use Android 5.0 or the API Level 21 in order to build your application, and 89 00:06:34,300 --> 00:06:39,370 that will work flawlessly on ninety four point one percent of devices that are out there. 90 00:06:41,040 --> 00:06:46,620 Now you can activate that you want to use legacy Android support libraries, which is if you really 91 00:06:46,620 --> 00:06:49,230 want to specifically target old devices. 92 00:06:49,380 --> 00:06:51,450 So I'm not going to check that box. 93 00:06:52,230 --> 00:06:56,760 Now let's click on finish and let Android Studio set up the project. 94 00:06:57,090 --> 00:07:02,940 You can see here that it says Gradle Colin Bell, and there is this progress bar, which basically just 95 00:07:02,940 --> 00:07:09,330 says, OK, it's preparing the project, so it's creating all of the code and all of the project files 96 00:07:09,330 --> 00:07:09,990 that there are. 97 00:07:11,830 --> 00:07:17,920 OK, so here you can see that you have your coach in the main activity, Katie, which is opened by 98 00:07:17,920 --> 00:07:20,410 default, but Katie stands for Scotland, by the way. 99 00:07:20,410 --> 00:07:26,050 So this is a coughlan file and it is a physical file on your PC. 100 00:07:26,320 --> 00:07:33,460 So if you want to go to this particular folder, you can right click and then go to open in Explorer. 101 00:07:33,790 --> 00:07:39,520 This will then open up the Explorer and you can find the system main activity key file, which isn't 102 00:07:39,520 --> 00:07:40,930 all of those sub folders. 103 00:07:41,170 --> 00:07:42,790 So there's the tutorials folder. 104 00:07:42,940 --> 00:07:47,950 Then you then Java Main C app. 105 00:07:48,430 --> 00:07:51,460 My first step and Android Studio for projects. 106 00:07:51,550 --> 00:07:58,270 So this is my first app, which contains all of those folders, which first IDG this Android Studio 107 00:07:58,300 --> 00:08:02,830 has automatically generated for us, and that really makes our life a lot easier. 108 00:08:03,430 --> 00:08:08,020 So you have this code, let's say you think that this code is too small or too big. 109 00:08:08,530 --> 00:08:15,280 What you can do is you can go over to your settings right here, or you can press control alt s on windows 110 00:08:15,850 --> 00:08:19,510 and then you can go to appearance and change the font. 111 00:08:19,750 --> 00:08:25,420 While this font here will not change, the code font will change the size of. 112 00:08:26,340 --> 00:08:33,270 This UI, for example, or the UI in general in your Android studio, I'm going to keep that at 18 because 113 00:08:33,270 --> 00:08:36,780 I believe that's just big enough for you to follow. 114 00:08:37,340 --> 00:08:43,140 But now if you want to change another font, you can just search for fonts here and then go to Editor 115 00:08:43,140 --> 00:08:45,360 Font and here you can change to size. 116 00:08:45,660 --> 00:08:49,980 So if you were to make it bigger, you would select a bigger value here. 117 00:08:49,980 --> 00:08:53,430 If you want to make it smaller, you would select the smaller value here. 118 00:08:53,760 --> 00:08:58,920 So I believe going with 20 is going to be fine for you. 119 00:08:59,100 --> 00:09:01,650 So this is going to be the size that we're going to use here. 120 00:09:02,760 --> 00:09:04,320 Now you can see that it has. 121 00:09:06,940 --> 00:09:09,910 Now, let's have a very quick overview of what's going on here. 122 00:09:10,330 --> 00:09:14,710 So on the left hand side, we have a bunch of buttons that we can click on and these are taps. 123 00:09:14,710 --> 00:09:17,350 So when I click on this, you can see that this closes. 124 00:09:17,650 --> 00:09:22,210 It's the Project tab, which allows me to see all of the project files. 125 00:09:22,570 --> 00:09:29,130 And here I can go to different settings, which will also change the way those files are displayed. 126 00:09:29,140 --> 00:09:33,220 So if I go to project, you can see that suddenly things look very differently. 127 00:09:33,520 --> 00:09:39,370 And I would recommend to always keep it at Android because that's how I'm going to use it, and it will 128 00:09:39,370 --> 00:09:41,380 make it easier for you to follow along. 129 00:09:41,740 --> 00:09:43,730 So consider a bunch of files, right? 130 00:09:44,200 --> 00:09:49,750 And most of them will not be relevant for us at the beginning, but we're going to go through them step 131 00:09:49,750 --> 00:09:52,000 by step and I'm going to explain what they do. 132 00:09:52,540 --> 00:09:56,710 Now, the most important file for us is going to be this main activity right here. 133 00:09:57,160 --> 00:10:02,350 And it's this file that has already opened and you can see once I click on it while it opens up this 134 00:10:02,530 --> 00:10:04,210 screen, it was open already. 135 00:10:04,210 --> 00:10:05,590 So let's go to another file. 136 00:10:05,620 --> 00:10:10,210 Let's go to this for file, for example, and I'll click on main activity and you see it jumps over 137 00:10:10,210 --> 00:10:10,510 here. 138 00:10:11,050 --> 00:10:16,480 So this is going to be the starting point of our application where everything starts. 139 00:10:18,560 --> 00:10:22,820 Now, at the same time, you see that there was a different file opened up for me as well. 140 00:10:23,270 --> 00:10:26,630 It's called the activity underscore mean that Axim L file. 141 00:10:26,870 --> 00:10:31,760 So this is the XML file, which takes care of the user interface. 142 00:10:31,880 --> 00:10:34,250 So let me drag this around a little bit. 143 00:10:34,250 --> 00:10:39,230 You can see there are many different options here what you can drag and change the appearance. 144 00:10:39,530 --> 00:10:46,940 So let me zoom in a little bit and you can see that this is basically going to be the UI of my application. 145 00:10:47,120 --> 00:10:51,620 So currently, the only thing that it has is this little text that says Hello world, and I can click 146 00:10:51,620 --> 00:10:56,000 on it and then I can see the attributes here on the right hand side and make changes to it. 147 00:10:56,240 --> 00:10:58,010 But we're not going to do that for now. 148 00:10:58,610 --> 00:11:05,000 Now the important part is that you see that there is a little editor which allows you to edit the UI 149 00:11:05,270 --> 00:11:11,150 and the main activity and activity underscore May next while they are connected, which basically means 150 00:11:11,150 --> 00:11:17,750 that this main activity uses this activity main L as its appearance, so to speak as its user interface 151 00:11:17,750 --> 00:11:18,080 file. 152 00:11:18,500 --> 00:11:21,050 Because here we are setting the content view. 153 00:11:21,290 --> 00:11:27,470 So we're saying the content in the view, which means on the screen should use this file called activity 154 00:11:27,470 --> 00:11:30,770 underscore main, which is this XML file right here. 155 00:11:32,630 --> 00:11:37,460 Now, this activity may XML file, by the way, is inside of this address here. 156 00:11:37,730 --> 00:11:43,220 So in the Java folder, that's what our programming code goes inside of the rest folder. 157 00:11:43,220 --> 00:11:44,840 That's where our resources go. 158 00:11:45,200 --> 00:11:48,440 And there are troubles which are images. 159 00:11:48,680 --> 00:11:52,530 So for example, this green image as well as this little robot. 160 00:11:52,550 --> 00:11:57,110 These two are images which in fact are vectors that then create this image. 161 00:11:57,590 --> 00:12:04,160 And then we have the layouts in which we have our activity main XML file, which is this file here, 162 00:12:04,520 --> 00:12:09,500 which we're going to adjust accordingly in order to make our app look differently. 163 00:12:10,070 --> 00:12:13,670 So this is just for you to know where files are the Gradle scripts. 164 00:12:13,670 --> 00:12:18,410 We're going to look at that a lot later because we're not going to patched it anytime soon. 165 00:12:20,140 --> 00:12:20,560 All right. 166 00:12:20,740 --> 00:12:24,820 But that's it for this video and the next one, we're going to set up the emulator.