Recently I have been wanting to learn the development of Android and so on, just now the time is more abundant, so decided to start from here my mobile development. Although the Web app based on HTML5 seems more popular now, I want to start with the native app development. I'm going to do my study based on Android Studio. Start building my first Android project below.
Create a project
First, we'll start by pointing out two concepts in Android studio. Project and Module. In Android studio, the real meaning of project is the workspace, Module for a specific project. In eclipse, we can simultaneously edit multiple Eclipse project at the same time, these project in the same workspace. In Android Studio, we can simultaneously edit several module of Android studio, which are in the same project.
Project Eclipse is the same as the Module for Android studio.
Eclipse's workspace is equivalent to Project in Android studio.
Explanation 1
The process of creating a project in Android Studio is actually a subdivision of Eclipse's process of creating a project. Eclipse Many of the content set on one page, Android studio split into multiple pages, so the process of creating a project is not complicated.
There are two ways to create a project in Android studio.
The first one is to select Start a new Android studio project on the Android Studio start page.
The second one is on the Android Studio home page, select File---New Project.
Explanation 2
Next, we'll see this page.
- Application name: The names of the applications. It is the app name that the app displays on the device, and also the name of the Android Studioproject.
- Company domain: Corporate domain name. Affects the following package name. The default is the computer host name, and of course you can set the package name separately.
- Package Name: the application bundle name. Each app has a separate package name, and if two apps have the same package name, Android will think they're the same app. As a result, it is necessary to ensure that different apps have different package names.
- The local directory where Project Localtion:project resides.
After setting up the above content, click Next.
Explanation 3
Next, we'll see this page.
Here you can type the Module in your Project and the minimum supported version.
Phone and tablet: Indicates that the Module is a 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 Module is a Google Glass project (do not know what Google Glass is, please search by yourself).
You can select multiple types at the same time, and the difference is that the project creates one or more Module based on the type you choose. The Minimum SDK represents the minimum Android version supported by the Module. Different versions can be selected depending on the user. You can click on the Help me choose to see the current version of Android distribution. Now in this era, if your project supports the 2.2 version almost all Android devices are supported. after the above content is set, click Next
Explanation 4
Next, we will see this page (because my Module type only selects Phone and Tablet, so this page will be available.) )。
This page is the type that lets us choose whether to create activity and create activity. You can choose not to create activity (Add no activity).
If you choose to automatically create Activity,android studio, it will automatically generate some code for you. The generated code is different depending on the Activity type. Sometimes you can learn a lot from these automatically generated code, such as Fullscreen Activity.
Select Finish, click Next.
Explanation 5
Next, we'll see this page (in the previous step, I chose the Blank Activity.) )。
- Activity Name: The class name of the activity that was created automatically.
- Layout Name: The configuration file name of the Activity that was created automatically.
- Title: The name of the Activity that was created automatically.
- Menu Resource Name: The menu file name of the Activity that was created automatically.
After setting up the above content, click Next. You will see this progress bar. This means that Android studio is creating and compiling your project.
Explanation 6
After the project is created and compiled, it will go to the home page of Android Studio and you will see the following interface.
On the left is your project file area, the middle is the code area, and the right side is the preview area of the layout file.
If you are careful, you will find that the file level shown in the project file area on the left is not the same as Eclipse, or even the file hierarchy of the local directory.
It's not the same as eclipse because Android Studio uses the Gradle project build tool, and Eclipse uses Ant build projects, and you can have the same directory structure through Gradle settings and Eclipse.
And the file level of the local directory is different because, after the Android Studio 0.8 version, the official recommended use of Android file directory display structure, you can switch. In the upper-left corner of the project file area, you can select the type of file structure display you want to select.
Although the official recommendation is to use Android, I personally prefer to use Project. You can choose according to your personal habits. The following are the display differences between the two display types: Android and project.
As can be seen from these two graphs: Android is clearly differentiated, showing only the files related to the project; project shows the structure of the file according to the local directory structure, which is more complicated but shows the real directory structure.
In addition, I have two settings for the project file area. In the upper-right corner of the project file area, there is a gear settings button that allows you to click on the settings file to display the results in more detail.
The default is not to tick Flatten Packages and AutoScroll to Source, is my own tick. Flatten Packages is set to display the package in the form of a full package name (personal habits). AutoScroll to Source is when you click on a file that will open automatically, eliminating the double-click operation.
Explanation 7
If you already have a project where you want to create a Module in this project, you can choose File-to-New module.
This creates a Module in the current directory instead of creating the Project and Module separately in a new window.
After that, you'll see the following interface.
Similarly, you can set the project type, but since you are now creating a Module, you only have to choose one type.
The 4 options below represent a different meaning:
- Android Library: Create a Module for the Android library.
- Import Existing Project: Importing another project as a Module, the imported project can be an Eclipse ADT project, or it can be a Gradle project (Gradle is just a project builder, which is also available in eclipse).
- Import. JAR or. AAR package: Import a JAR or AAR file as a Module.
- Java Library: Create a Java Module that is used primarily to write Java toolkits.
Select Finish, click Next. The rest of the steps, almost the same as above, are not in the repeating.
Original Address HTTP://ASK.ANDROID-STUDIO.ORG/?/ARTICLE/20
Android Learning Path (i) Android Studio Create Project