5: Android Studio Project Creation, androidstudio
Author: Guo Xiaoxing
Weibo: Guo Xiaoxing's Sina Weibo
Email: allenwells@163.com
Blog: http://blog.csdn.net/allenwells
Github: https://github.com/AllenWell
First, describe the two concepts involved in the creation of the Android Studio project.
- Project: Workspace
- Module: a specific project
Correspondence
In Eclipse, we can simultaneously edit multiple projects in the same Workspace. In Android Studio, we can simultaneously edit multiple Android Studio modules in the same Project.
- The Eclipse Project is equivalent to the Module of Android Studio.
- The Workspace of Eclipse is equivalent to the Project of Android Studio.
The Project mentioned in this Article refers to the Module of Android Studio. To create a Project in Android Studio, you must first create a Project. However, when you create a Project, the Project is automatically created,
1. process for creating an Android Studio Project
Next we will create a new project step by step.
(1) Configure your new project
As shown in:
- Application name: name of the Application. It is the name of the App displayed on the device and the name of the App Project in Android Studio.
- Company Domain: the Company Domain name. The following Package name is affected. The default value is the host Name. You can also set the Package Name separately.
- Package name: application Package name. Each App has an independent package name. If the two apps have the same package name, Android considers them the same App. Therefore, make sure that different apps have different package names.
- Project localtion: local directory of the Project.
(2) Select the form factors your app will run on
As shown in:
Here, you can set the Module type and the supported minimum version in your Project.
- Phone and Tablet: indicates that the Module is a mobile Phone and Tablet project.
- TV: indicates that the Module is an Android TV project.
- Wear: indicates that the Module is a wearable device (such as a watch) project.
- Glass: indicates that the Module is a Google Glass Project (please search for what Google Glass is ).
You can select multiple types at the same time. The difference is that the project will create one or more modules based on the type you choose.
The Minimum SDK indicates the Minimum Android version supported by the Module. You can select different versions based on your needs. You can click Help me choose to view the distribution of the current Android version. In this era, if your project supports almost all Android devices to Version 2.2.
(3) Add an activity to Mobile
As shown in:
This page shows you how to create an Activity and the type of the Activity. You can choose not to create Activity (Add No Activity ).
If you choose to automatically create an Activity, Android Studio will automatically generate some code for you. The generated code varies depending on the Activity type. Sometimes, you can learn a lot from these automatically generated code, such as Fullscreen Activity.
(4) Customize the Activity
As shown in:
- Activity Name: The Class Name of the automatically created Activity.
- Layout Name: Name of the Layout file of the automatically created Activity.
- Title: name of the automatically created Activity.
- Menu Resource Name: Name of the Menu file of the automatically created Activity.
After the above four steps, we have created the Project, which contains a default Module. We can also create a New Module through FIle-> New Module.
When creating a Module, there are four options, which have the following meanings:
- Android Library: Creates a Module for the Android Library.
- Import Existing Project: Import other projects into a Module. The imported Project can be an Eclipse ADT Project or a Gradle Project (Gradle is only a Project building tool and can also be used in Eclipse ).
- Import JAR or AAR Package: Import a JAR or AAR file as a Module.
- Java Library: Creates a Java Module, which is mainly used to compile Java toolkit.
2. Android Studio project structure
Android Studio supports displaying the project hierarchy in three different ways.
- Project: The level is responsible, but the actual file directory structure is displayed.
- Package: displays the structure of all packages, including code and related resources.
- Android: officially recommended. Only project-related files are displayed.
The three modes are shown in:
Project
Package
Android
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.