Creating the Fun Facts Project6:11 with Ben Deitch
In this video we'll walk through setting up a new app project in Android Studio. At last, we get to create something!
To make sure this course looks good in the future, I'm using Android Studio 3.0 which is currently in Beta. If you're on an older version of Android Studio things might look slightly different. Though don't feel like you need to be using the Beta version, Stable will work just fine :)
Also, if you're on an older version of Android you may need to set up your project with Kotlin. Instructions on how to do that can be found here
Need to import project files? All you do is select File -> Open from the Android Studio menu and then navigate to the FunFacts folder that you unzip from the project files. When you have that folder selected, click 'OK' and the project will be opened in a new Android Studio window.
If you have any capital letters in your package name you'll get this error when building your app:
Before we start any work, I want to stress one very important thing. 0:00 Don't be afraid to make mistakes with this stuff. 0:04 You can learn so much about programming from making mistakes, and 0:07 then fixing them. 0:10 You can always undo things, and if you really mess up, you 0:11 can download the project files for each video, or even start over from scratch. 0:14 Check the teacher's notes for a link about how to import project files. 0:19 And again, we're here to help. 0:22 Head over to the community with any questions or problems. 0:24 All right, we're ready to start programming. 0:28 Let's get started with our Fun Facts app. 0:31 We're going to approach this as an iterative process. 0:33 And we'll start with a very simple version that simply displays one fun fact 0:36 all the time. 0:41 It won't be very useful or fun yet, but it will introduce us to the tools we will use 0:42 as well as verify everything is working correctly on our computers. 0:47 All right, with Android Studio open, 0:52 let's select start a new Android project from the top of the list. 0:54 We're going to start with the application name, which is the name of our app. 1:01 Let's type Fun Facts with two capital Fs and a space in between. 1:05 We want this to look exactly how we want it to appear on the device or 1:10 in the Google Play Store. 1:14 Also, the application name can only consist of letters, numbers, spaces, 1:16 or underscores. 1:21 Next, we have the company domain, which is where you can put your own name or 1:23 the organization you work for. 1:27 I'll leave mine as teamtreehouse.com, but feel free to use your own. 1:30 Notice that the package name matches the company domain and the application name. 1:34 It changes based on what we type, although we can go over here and 1:39 click on edit if we wanna change it ourselves. 1:44 Just don't add any capital letters to your package name. 1:47 That's asking for trouble. 1:50 The package name is important because it's used to differentiate our app 1:52 from others in the play store. 1:56 If there's another Fun Facts app on the Playstore with the same name, 1:58 then we need something besides just the application name to tell them apart. 2:02 The package name makes them unique. 2:06 The application name gets appended to the package name, so 2:09 that apps by the same organization can be grouped together by a common package name. 2:13 So all team tree house apps will start with com.teamtreehouse. 2:18 We can change the package name later on if we need to, but it's kind of a hassle, so 2:24 it's best to get it right here at the start. 2:28 We especially don't wanna change it after we publish our app. 2:31 The package name must be exactly the same in order to make any 2:35 updates to an existing app. 2:38 Next, since we're using Kotlin, 2:41 let's check the Include Kotlin Support check box. 2:43 Down here, is the project location on your computer. 2:47 I'll leave mine as is, but feel free to change this. 2:50 Then click Next. 2:54 Now we need to pick devices and version of Android that our app can run on. 2:56 This can be a little overwhelming at first. 3:01 But let's keep it simple, and leave Phone and Tablet checked. 3:03 We'll be writing this app to work on a phone and it will also work on tablets. 3:08 But we aren't going to optimize how it looks on tablets. 3:12 Now we need to pick the minimum SDK, which stands for Software Development Kit. 3:16 The Android SDK and API levels are often used interchangeably. 3:21 There's a one to one relationship. 3:26 Meaning each version of the SDK has a corresponding API number. 3:29 Also we've got a helpful message here. 3:34 Lower API levels target more devices but have fewer features available. 3:37 By targeting API 15 and later, your app will run 3:42 on approximately 100% of the devices that are active on the Google Play Store. 3:46 Okay, but what does this mean? 3:52 Let's click on the Help me choose button to find out. 3:55 This brings up a graph showing the distribution of 3:59 Android versions out in the wild. 4:02 And what this shows us is that of all devices, 100% of them are on 4:04 Android 4.0 or above and that corresponds to API level 15. 4:09 So we can feel very safe in picking API level 15 for our app. 4:14 Okay, but what about the very latest version of Android? 4:20 Well, we're targeting API 15 and up, 4:24 which means that our app should run on each release as it comes out. 4:27 The API level really only comes into play when we're using features that either lose 4:31 support or are brand new. 4:36 The Fun Facts app focuses on the basics though, so this isn't an issue. 4:38 The big difference for us is that Android will apply some basic visual modifications 4:43 based on which SDK version the app is using. 4:48 All right, let's hit OK to leave this screen, 4:51 then make sure API 15 is selected and hit Next. 4:55 On this screen, we see a list of pre-built activities that we can choose from. 5:00 In Android, 5:05 activities can be thought of as the different screens that make up an app. 5:06 Starting from an already built activity can definitely make building an app 5:10 a little easier. 5:14 But since we're still learning, we'll use the fourth option, the Empty Activity. 5:15 Let's select it and click Next. 5:21 And now we want to pick a name for our activity. 5:25 Typically we'll want something like MainActivity for the main 5:28 activity in the app, or a name that describes what the activity is or does. 5:31 Since were showing fun facts, let's name ours, [SOUND] FunFactsActivity. 5:37 Notice that as we change the name, the layout name changes as well. 5:44 Cool, now we can finish, and 5:48 Android Studio will take a minute to build our project. 5:51 And after a short delay, we should have everything ready to go. 5:54 And what we have here is a project to show that's pretty much ready to run. 5:58 It's a full fledged app albeit a very boring one. 6:03 In a moment we'll come back and run it to make sure everything is working. 6:07
You need to sign up for Treehouse in order to download course files.Sign up