Create an Android project and an android Project

Source: Internet
Author: User

Create an Android project and an android Project

An Android project contains all the source code in the App.

This article shows how to create a new project through the command line in AndroidStudio or SDKTool.

Note:You should have installed AndroidStudio or AndroidSDK. If not, go to the previous article.

Create a project using Android Studio

1. Use Android Studio to create a new project:

2. InConfigure your new project Interface, Fill in the corresponding content as shown in the figure, and clickNext.

The fields are as follows:

    • Application NameIs the name of the App displayed to the user. For example, "My Application"
    • Company domainThe company name here is equivalent to a qualifier and will be added to the package name. Android Studio will record the company name entered during the last creation of the new project.
    • Package nameThe unique name of the project, that is, the so-called package name (which must comply with the Java language package naming rules ). in all apps installed in Android, your package name must be unique. you can clickEditTo modify the default package name.
    • Project locationThe directory where the project is located.

3.Select the form factors your app will run on Interface, SelectPhone and Tablet.

4.Minimum SDK, SelectAPI 10: Android 2.3.3 (Gingerbread).

The Minimum SDK is the Minimum Android version supported by your app and the API level that you can use in coding. to support more devices, you should select the lowest possible system version based on the core features of your app. if there are any features in the app that can only run on a later version but are not the core function, you can choose to make some version adaptation. These new features are only enabled when running on a later version. For more information, see (compatible with different system versions ).

5. Keep all the remaining options (TV, Wear, and Glass) unselected, and then clickNext.

6. InAdd an activity to mobileInterface, selectBlank ActivityClickNext. (Select the appropriate activity template based on the project requirements)

7. InCustomize the ActivityInterface,ActivityNameMainActivity.Layout NameNameActivity_main,TitleNameMainActivity.Menu Resource NameMenu isMenu_main.

Activities

Activity is one of the four main components of the Android framework. Activity provides users with access to your application, and there may be many activities in an app. An application usually has a major Activity to start the application for the user. When the user selects some content on the interface, for example, when she and other activities execute other tasks. For more information, see Activities.

8. ClickFinishTo create the app.

At this time, your "HelloWorld" app has been created, including some default files. Please familiarize yourself with some important things:

App/src/main/res/layout/activity_main.xml

When you create a project through AndroidStudio, a layout file corresponding to Activity is automatically generated. In the latest development tools, Android Studio provides two editing modes: the traditional code editing mode and the visual layout editing mode. this layout file contains some default settings and addsTextView element, which displays a sentence, "Hello world! "

App/src/main/java/com. netease. myapplication/MainActivity. java

After you create a workflow for a new project through AndroidStudio, a tab corresponding to the file appears in the editing window. When you select this file, you can see that the class corresponding to this Activity is created in this file. Finally, when you compile and run the app, the Activity class runs and "Hello world!" is displayed on the screen! "

App/src/main/AndroidManifest. xml

Manifest file, which literally represents a list, describes the basic features of an application and defines each of its components (refer to the four Android components ). In the subsequent tutorials, you will constantly review this file and add various components to it.

App/build. gradle

Android Studio uses Gradle to compile and generate our app. Each module in the project hasBuild. gradle, of course, also hasThe build. gradle file corresponds to a complete project. Generally, you only need to pay attention tobuild.gradleFile. This is where the app compilation and dependency are located. The configuration file also containsDefaultConfig:

    • compiledSdkVersionThis value indicates the sdk version used for compiling your app. By default, weThe latest sdk is generally used.For example, here we use 22. (Google will officially recommend more than 4.1, so the adaptation rate is higher; if not, use SDK Manager to install one ). You can choose to develop an app that supports older versions such as 2.3.3 or 4.0.3.MinSdkVersion Control), But this setting requires the latest version number, so that you can get the most friendly experience on some of the latest devices, and even the code can run different effects on different system versions.
    • applicationIdIs the complete app package name that you defined when creating a project.
    • minSdkVersionThis value is the minimum system version supported by the app mentioned above. It is usually set when you create a project.
    • targetSdkVersionIndicates the highest System Version tested by the developer. With the release of the latest Android version, you should test your app on the latest system version and update this value to match the latest API level. For more information, see support for multi-platform development.

If you want to know

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.