1 00:00:00,410 --> 00:00:05,170 Before we start any work I want to stress one very important thing, 2 00:00:05,170 --> 00:00:07,650 don't be afraid to make mistakes with this stuff. 3 00:00:07,650 --> 00:00:12,560 You can learn so much about programming from making mistakes and then fixing them. 4 00:00:12,560 --> 00:00:15,740 You can always undo things and if you really mess up, you can 5 00:00:15,740 --> 00:00:20,110 download the project files for each video or even start over from scratch. 6 00:00:20,110 --> 00:00:23,710 Check the teacher's notes for a link about how to import project files, and 7 00:00:23,710 --> 00:00:25,770 again, we're here to help. 8 00:00:25,770 --> 00:00:29,500 Head over to the community with any questions or problems. 9 00:00:29,500 --> 00:00:32,130 All right, we're ready to start programming, 10 00:00:32,130 --> 00:00:34,700 let's get started with our Fun Facts app. 11 00:00:34,700 --> 00:00:37,670 We're going to approach this as an iterative process, and we'll 12 00:00:37,670 --> 00:00:43,390 start with a very simple version that simply displays one fun fact all the time. 13 00:00:43,390 --> 00:00:48,150 It won't be very useful or fun yet, but it will introduce us to the tools we'll use, 14 00:00:48,150 --> 00:00:51,550 as well as verify that everything is working correctly on our computers. 15 00:00:52,640 --> 00:00:55,180 All right, with Android Studio open, 16 00:00:55,180 --> 00:00:59,690 let's select Start a new Android Studio project from the top of the list. 17 00:00:59,690 --> 00:01:03,126 We're going to start with the application name which is the name of our app. 18 00:01:03,126 --> 00:01:09,390 Let's type Fun Facts with two capital letter Fs and a space in between. 19 00:01:09,390 --> 00:01:13,140 We want this to look exactly how we want it to appear on the device or 20 00:01:13,140 --> 00:01:14,690 on the Google Play Store. 21 00:01:14,690 --> 00:01:19,673 Also the application name can only consist of letters, numbers, spaces, 22 00:01:19,673 --> 00:01:21,310 or underscores. 23 00:01:21,310 --> 00:01:25,350 Next we have the company domain, which is where you can put your own name or 24 00:01:25,350 --> 00:01:27,470 the organization you work for. 25 00:01:27,470 --> 00:01:30,940 I'll leave mine as teamtreehouse.com, but feel free to use your own. 26 00:01:31,980 --> 00:01:35,230 Notice that the package name matches the company name and 27 00:01:35,230 --> 00:01:39,650 the application name, it changes based on what we type. 28 00:01:39,650 --> 00:01:44,820 Although we can go over here and click on Edit if we want to change it ourselves. 29 00:01:44,820 --> 00:01:49,180 Just don't add any capital letters to your package name, that's asking for trouble. 30 00:01:49,180 --> 00:01:52,750 The package name is important because it's used to differentiate our app 31 00:01:52,750 --> 00:01:54,590 from others on the Play Store. 32 00:01:54,590 --> 00:01:58,400 If there's another Fun Facts app on the Play Store with the same name, 33 00:01:58,400 --> 00:02:02,160 then we need something besides just the application name to tell them apart. 34 00:02:02,160 --> 00:02:04,580 The package name is what makes them unique, 35 00:02:04,580 --> 00:02:08,035 the application name gets appended to the package name so 36 00:02:08,035 --> 00:02:13,150 that apps by the same organization can be grouped together by a common package name. 37 00:02:13,150 --> 00:02:18,910 So all Team Treehouse apps will start with com.teamtreehouse. 38 00:02:18,910 --> 00:02:23,220 We can change the package name later on if we need to, but it's kind of a hassle, so 39 00:02:23,220 --> 00:02:25,610 it's best to get it right here at the start. 40 00:02:25,610 --> 00:02:29,800 We especially don't want to change it after we publish our app, the package name 41 00:02:29,800 --> 00:02:34,450 must be exactly the same in order to make any updates to an existing app. 42 00:02:34,450 --> 00:02:37,763 Down here is the project location on your computer, 43 00:02:37,763 --> 00:02:42,146 I'll leave mine as is but feel free to change this, then click Next. 44 00:02:44,953 --> 00:02:49,430 Now we need to pick devices and version of Android that our app can run on. 45 00:02:49,430 --> 00:02:53,360 This can be a little overwhelming at first, but let's keep it simple and 46 00:02:53,360 --> 00:02:55,520 leave phone and tablet checked. 47 00:02:55,520 --> 00:02:59,400 We'll be writing this app to work on a phone and it will also work on tablets, 48 00:02:59,400 --> 00:03:02,320 but we aren't going to optimize how it looks on tablets. 49 00:03:02,320 --> 00:03:07,600 Now we need to pick the minimum SDK, which stands for software development kit. 50 00:03:07,600 --> 00:03:09,380 The Android SDK and 51 00:03:09,380 --> 00:03:14,270 API levels are often used interchangeably, there's a one to one relationship. 52 00:03:14,270 --> 00:03:18,700 Meaning each version of the SDK has a corresponding API level, 53 00:03:18,700 --> 00:03:21,190 also we've got a helpful message here. 54 00:03:21,190 --> 00:03:26,200 Lower API levels target more devices but have fewer features available. 55 00:03:26,200 --> 00:03:27,635 Okay, but what does this mean? 56 00:03:27,635 --> 00:03:30,340 Let's click on the Help me choose button to find out. 57 00:03:31,750 --> 00:03:35,170 This brings up a graph showing the distribution of Android versions 58 00:03:35,170 --> 00:03:39,980 out in the wild, and what this shows us is that 97.4% 59 00:03:39,980 --> 00:03:43,910 of devices are on Android 4.0 or above. 60 00:03:43,910 --> 00:03:47,120 That corresponds to API level 15, so 61 00:03:47,120 --> 00:03:51,560 we can feel fairly safe in picking API level 15 for our app. 62 00:03:51,560 --> 00:03:55,610 Another nice thing about not using the lowest API level is that we don't need to 63 00:03:55,610 --> 00:03:59,400 make any additional changes to make our app backwards compatible. 64 00:03:59,400 --> 00:04:02,860 Okay, but what about the very latest version of Android? 65 00:04:02,860 --> 00:04:05,410 Well, we are targeting API 15 and 66 00:04:05,410 --> 00:04:10,220 up, which means that our app should run on each release as it comes out. 67 00:04:10,220 --> 00:04:12,790 The API level really only comes into play 68 00:04:12,790 --> 00:04:16,570 when we're using features that either lose support or are brand new. 69 00:04:16,570 --> 00:04:21,030 The Fun Facts app focuses on the basics though, so this isn't an issue. 70 00:04:21,030 --> 00:04:25,330 The big difference for us is that Android will apply some basic visual modifications 71 00:04:25,330 --> 00:04:28,310 based on which SDK version the app is using. 72 00:04:28,310 --> 00:04:31,699 All right, let's hit OK to leave this screen, 73 00:04:31,699 --> 00:04:35,190 then make sure API 15 is selected and hit Next. 74 00:04:37,260 --> 00:04:41,350 On this screen, we see a list of pre-built activities that we can chose from. 75 00:04:41,350 --> 00:04:42,290 In Android, 76 00:04:42,290 --> 00:04:46,210 activities can be thought of as the different screens that make up an app. 77 00:04:46,210 --> 00:04:49,990 Starting from an already built activity can definitely make building an app 78 00:04:49,990 --> 00:04:51,320 a little easier. 79 00:04:51,320 --> 00:04:55,250 But since we're still learning, we'll use the fourth option, the Empty Activity. 80 00:04:56,870 --> 00:05:03,670 Let's select that and click Next, and now we want to pick a name for our activity. 81 00:05:03,670 --> 00:05:07,220 Typically, we'll want something like MainActivity for the main activity in 82 00:05:07,220 --> 00:05:11,840 the app, or a name that describes what the activity is or does. 83 00:05:11,840 --> 00:05:15,931 Since we're showing fun facts, let's name our's FunFactsActivity. 84 00:05:19,750 --> 00:05:24,840 Notice that as we change the name, the layout name changes as well, cool. 85 00:05:24,840 --> 00:05:29,160 Now we can finish and Android Studio will take a minute to build our project, and 86 00:05:29,160 --> 00:05:32,020 after a short delay, we should have everything ready to go. 87 00:05:40,965 --> 00:05:45,240 You'll notice that Android Studio by default shows the tip of the day. 88 00:05:45,240 --> 00:05:49,250 You can choose to not see tips if you want, but I recommend leaving the tips on 89 00:05:49,250 --> 00:05:53,320 because you can learn helpful keyboard shortcuts or other useful information. 90 00:05:53,320 --> 00:05:54,778 I'll close that to get it out of the way. 91 00:05:59,028 --> 00:06:03,146 And what we have here is a project shell that's pretty much ready to run, 92 00:06:03,146 --> 00:06:06,670 it's a full fledged app, albeit a very boring one. 93 00:06:06,670 --> 00:06:10,060 In a moment we'll come back and run it to make sure everything is working.