After installing Android Studio and configuring the Android SDK, you're ready to create your first project. You can do this right from the Welcome Screen by clicking on New Project. On this New Project screen, set your application name. You can then set the package name. This is a globally unique string that identifies the application in application stores, on devices and anywhere where Android apps live. Typically, the package name starts with your domain in reverse domain notation to ensure its uniqueness.
- [Voiceover] You can create a brand new Android Studio project from the welcome screen. Just click the first option labeled Start a new Android Studio project. On the first screen, assign an application name. This can be any string at all. That string will be used in a number of ways. It'll be used to set a default package name, which I'll describe in a moment, but it will also be used to label the app when it's deployed to Android devices. I'll change my application name to My First App.
Next is the company domain. This can be anything you like, but should reflect your own domain. It won't actually be used in the final app. It's used to create the package name. Each app has a package name, also known as the application identifier. It has to be a globally unique string, and the best way to get that uniqueness is to start with your company or organization's domain, and then use a Java style package name. This will also be used as the main package for your Java classes.
Whatever you set as your company domain will be translated as the package name. If I change this from david.example.com, to android.example.com, I see the package name being changed also. If you don't like the package name that's being generated, just click the Edit link on the right, and then you can change it. I'll change my package name to com.example.android.sample, and I'll use this same package throughout the entire course, so I'm not creating a whole bunch of different apps on my devices.
Next is the project location. The default location will be in a folder that's named for the app, but without any spaces, and is placed in a folder named AndroidStudioProjects under your home directory. This directory is not like Eclipse workspaces. It's just a directory, and it doesn't contain any configuration information, and if you don't like that location, you can easily change it to whatever you want. I'll accept that location though, and click Next. On this screen, you're asked which form factors your app will run on.
In Android Studio 2.0, you can build apps for phone and tablet, for Android Wear, or watches, for Android TV, Auto, and Google Glass. In this course I'll only be focusing on phone and tablet apps. You also set your minimum SDK on this screen. The minimum SDK indicates the oldest version of Android that your app will run on. The default is API 15 for Android 4.0.3 Ice Cream Sandwich.
If you want to support older Android devices, you can go back to Android 3, or even Android 2.3 or 2.2. If you're not sure which devices you want to support, you can click on this link and it'll take you to this listing of the various API levels and the approximate distribution. According to this screen, if I support Ice Cream Sandwich, I'll be covering almost 95% of the current device market. You can find more current information by going to this page, the dashboards page on the developer website, and you'll see the most recent survey information showing you the various percentages for each version of Android.
As of the most recent survey, as of the time of this recording, Android 2.2 was only covering .1%, almost nothing, but Android 2.3 Gingerbread, or API 10, was representing almost 3% of the market. It's up to you to decide which versions of Android you want to support, but just know by going back to Gingerbread, you'll have to do a lot more testing to make sure your app works on all those different versions. I'll go back to Android Studio and continue with the process by clicking Next.
On this screen, you're asked what kind of activity you want to add to your mobile app. An activity in Android is a screen, and by default, each new app that you create through Android Studio will have one starting screen. The default in Android Studio 2.0 is an empty activity. That's a screen with only a bit of text displayed. There are a lot of much more complex activity templates available, including the basic activity template that adds a floating action bar in the lower-right hand corner of the screen.
Full screen activities, activities with ads, maps, login screens, and much more. For this course, I'll primarily be using the default activity template, the empty activity. On this screen, I'm asked to name the components in my app. The number of items you're asked to provide will depend on which activity template you chose. For this very simple empty activity template, you're only asked for the name of the activity that will generate a Java class and the name of a layout file that will be used to name an XML file.
I'll accept the default settings for those values, and click Finish, and that will result in creating my first app. The first time you create a project in Android Studio, it might take a while to download certain components, and then build the app and get it ready for processing, but after that, creating additional projects should go pretty quickly. Once the project has opened, you can then close the Tip of the Day dialog, and if you don't want to see it again, just uncheck this option, and then you can double click on the title bar to expand Android Studio to fill the screen.
If you've gotten this far, then your Android Studio project has been created, and you're ready to customize it, and then run it on Android devices.
- Installing Android Studio on Mac and Windows
- Creating Android Studio projects
- Setting up the development environment, including HAXM and the new Android emulator
- Importing existing code into Android Studio projects
- Exploring the interface, including the editor and project windows
- Managing project builds and dependencies
- Creating new Java classes
- Refactoring code
- Using templates
- Using breakpoints and watch expressions
- Updating apps with Instant Run
- Using Git for version control
Skill Level Beginner
Q: This course was updated on 04/27/2017. What changed?
A: New videos were added that highlight the new features introduced in Android Studio 2.3. In addition, the following topic was updated: update apps with Instant Run.