Creating an Android Project
This lesson shows you how to create a new Android project with Android Studio and describes some of the files in the project.
Now take a moment to review the most important files. First, be sure that the Project window is open (select View > Tool Windows > Project) and the Android view is selected from the drop-down list at the top. You can then see the following files:
- In Android Studio, create a new project:
- In the New Project screen, enter the following values:
- Application Name: "My First App"
- Company Domain: "example.com"
- Click Next.
- In the Target Android Devices screen, keep the default values and click Next. The Minimum Required SDK is the earliest version of Android that your app supports, which is indicated by the API level. To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set. If any feature of your app is possible only on newer versions of Android and it's not critical to the core feature set, enable that feature only when running on the versions that support it (see Supporting Different Platform Versions).
- In the Add an Activity to Mobile screen, select Empty Activity and click Next.
- In the Customize the Activity screen, keep the default values and click Finish.
Now take a moment to review the most important files. First, be sure that the Project window is open (select View > Tool Windows > Project) and the Android view is selected from the drop-down list at the top. You can then see the following files:
- app > java > com.example.myfirstapp > MainActivity.java
- This file appears in Android Studio after the New Project wizard finishes. It contains the class definition for the activity you created earlier. When you build and run the app, the
Activity
starts and loads the layout file that says "Hello World!" - app > res > layout > activity_main.xml
- This XML file defines the layout of the activity. It contains a
TextView
element with the text "Hello world!". - app > manifests > AndroidManifest.xml
- The manifest file describes the fundamental characteristics of the app and defines each of its components. You'll revisit this file as you follow these lessons and add more components to your app.
- Gradle Scripts > build.gradle
- Android Studio uses Gradle to compile and build your app. There is a
build.gradle
file for each module of your project, as well as abuild.gradle
file for the entire project. Usually, you're only interested in thebuild.gradle
file for the module. in this case theapp
or application module. For more information about this file, see Building Your Project with Gradle.