After installing all of the required software, you can create your first project for Android O. I'll show you the changes you should make in your application manifest and Gradle build files.
- [Instructor] After installing all of the required software, you can create your first project for Android O. From the welcome screen, I'll start a new Android Studio project, and I'll name it HelloAndroidO. I'll click Next, and I'll accept the minimum SDK of API 15. On this screen, I'll choose the bottom navigation activity, a new template that was added in Android Studio 2.3. I'll click Next again, and then Finish, and that creates my new project.
The first time you create a project, you might see the Tips dialog. You can just dismiss it and continue along. The first file that opens is the layout file activity_main.xml. You can look at it in design view if you like, but I won't be using this in this exercise so I'll close it. Then I'll go to the project window and switch to the Android scope. In the Gradle Scripts section, I'll open build.gradle from the app module. Here are some changes you'll want to make if you want to target Android O in an application.
First of all, the compile SDK version might be set to your most recent API level other than Android O. Change that to android dash O wrapped in quotes. It's lower-case android, a dash, and then an upper-case O. Again, that's an O and not a zero. Next, change your target SDK version and that's just the letter O, once again wrapped in quotes. If you wanted to set the minimum SDK version to Android O, you would set it the same way, like that, but I'll leave that set to API level 15.
Those are all the required changes, but here are some optional ones. You can set your build tools version to the most recent version that's been installed on your computer. On mine, that's 26 dot zero dot zero, dash rc1. If you're not sure of the version you have, look at your SDK manager. Then down at the bottom of the file under dependencies, you can match your support libraries to your target version. The easiest way to do this for a testing application is to set all of the support libraries that are using 25 dot something, to 26 dot plus.
That means a major version of 26 and a minor version of whatever is available. I'll make that change for the app compat library, and also for the design library, and finally for the new vector drawable library. You'll see warning indicators appear and you can get rid of those warning indicators by using an intention action, and adding the no inspection comment to each of those lines. I'll add it once here, and I'll duplicate it and move it down to the next one, and duplicate it again and move it down to the next one.
All of the warning indicators go away. To test and make sure I've done everything correctly, I'll click the sync now link at the top, and that resyncs my gradle build. Then I'll go to the menu and select Build, Make Project, and if everything runs without an error, I'm ready to test my app, but to do that, I'd like a device that's running Android O. I'll show you how to set that up in the next video.
- Installing Android Studio 2.4 Preview
- Targeting Android O in a new project
- Setting up Android O testing devices
- Exploring the new features for users
- Using display notifications in channels
- Using Autofill EditText components
- Displaying video as picture-in-picture
- Exploring other new features for developers