Android Development Android Studio2.0 tutorial from Getting Started to mastering Windows Edition-Introductory article

Source: Internet
Author: User
Tags uppercase letter jcenter

First article

Describes the Android Studio development environment and the genymotion virtual machine installation method, this section will show you how to develop your app using Android Studio.

Development of the first application

can develop their own applications, whether a little excitement? All right! Let's start by clicking Start a new Android Studio project to create the project:

Next you need to enter the app name (the first letter to capitalize), the company domain and the specified app directory, and click the Next button to enter the next step:

If the first letter is not uppercase, you are prompted:The application name for most app begins with an uppercase letter

Next you need to choose which device to develop (optional "phone and tablet", "Wearable (Wear)", "TV", "on-board (Android Auto)", etc.), and determine the minimum SDK version number.

The purpose of the Minimum SDK is to verify the Android version of the device before the app is installed, and prevent users from installing apps if the device's Android version is below this minimum version.

If you do not know how to choose the minimum version you can click on the Help me choose to see the distribution charts and descriptions for each version:

To continue clicking on the Next button, we need to choose our first activity style through a friendly GUI template:

Then you need to give the activity and layout a name.

When you click the Finish button, Android Studio starts to create and compile the app. Once the compilation is complete, we can see the IDE interface of Android Studio.

As you can see from the diagram, Android Studio has helped us to organize the project well.

Interface Introduction

As shown, I will divide the interface into 5 areas to do a detailed explanation:

Area 1 Introduction

This area is a run-and-debug-related operation.

1. The module shown in compiling 2

2, the current project module list

3. Run the module shown in 2

4. Module shown in Debug 2

5. Module code coverage shown in test 2

6, debugging the process of Android operation

7. Re-run the module shown in 2

8. Stop running the module shown in 2

Area 2 Introduction

This area is primarily related to Android devices and virtual machine operations.

1, virtual device management.

2, synchronous project Gradle files, generally in the Gradle configuration is modified when the need to synchronize.

3, project structure, some project-related property configuration.

4. Android SDK Management

5, Genymontion Simulator (need to install genymontion plug-in, installation Chapter [simulator installation] part)

Area 3 Introduction

This area is mainly related to engineering file resources and other relevant operations.

1, display the project document organization way, by default is displays by the Android way, may choose "Project, Packages, scratches, projectfiles, problems ..." and so on display way. The most common use of Android and project two kinds.

2. Locate the location of the current open file in the project directory.

3. Close all the expansion items in the project catalog.

4, some additional system configuration, the point is opened after a popup menu:

AutoScroll to source and AutoScroll from source two, Android studio automatically locates the location of the current edit file in the project, which will be very cool to use. Other features you can explore with your own.

Area 4 Introduction

This area is primarily used to write code and design layouts.

1. The tab page of the open file. (Pressing CTRL + click on the tab page will bring up a pop-up menu that will surprise you!) )

2. UI Layout Preview area.

3, layout editing mode switch, for some older birds prefer to edit the layout by text, Novice can try design editing layout, edit and then switch to text mode, for learning Android layout design is very helpful.

Area 5 Introduction

Most of this area is used to view some output information.

1, terminal-like the command line operation of the partners do not have to start the terminal.

2. Monitoring-can view some output information of the application.

3. Information-Some output information of project compiling.

4. Run-Some relevant information after the application is run.

5. TODO-a list labeled Toto notes.

6. Events-some event logs.

7, Gradle console, through this can understand Gradle build applications when some output information.

Android Studio Directory Structure

1, Gradle compilation system, version specified by wrapper

2. Files required by Android Studio IDE

3. Storage directory of application related files

4. Related files generated after compiling

5. Store dependent libraries

6. Code Storage Directory

7. resource file storage directory (including: layout, image, style, etc.)

8, the basic information list of the application, describes which components are present

9, git version management ignore files, mark out which files do not go into the git library

10. Engineering files for Android Studio

11, the Gradle related configuration of the module

12. Code Obfuscation rule Configuration

13, the Gradle related configuration of the project

14. Gradle Related Global property settings

15. Local Property settings (key settings, Android SDK location, etc.)

Application Development Debugging

As shown in 1, click the Set breakpoint at the line number you want to debug, then click the Debug button shown in 2 (or press the SHIFT+F9 shortcut key directly) to start debugging.

The debug view appears below the Android studio shown.

1, the current program stops the line of code

2. Some buttons related to debugging

3. The program calls the stack area, which shows all the methods that the program executes to the breakpoint, and the lower the earlier is called.

4. Local variable Observation Area

5. User-defined variable observation area

1, Step over (F8)-The program executes a line down, if the current line has a method call, this method is finished to return, and then to the next line.

2, Step into (F7)-The program executes a line down, if the current row has a user-defined method (non-official class library method) call, then enter the method.

3. Force Step into (ALT+SHIFT+F7)-The program executes a line down and enters the method if there is a method call on the current line.

4, Step out (SHIFT+F8)-If you enter a method when debugging, and feel that the method is not a problem, you can use Step out of the method, return to the method is the next line of the use of the statement. It is worth noting that the method has been executed.

5. Drop Frame-After clicking the button, you will return to the current method's call to execute again, and the value of all context variables will return to that time. You can jump to any of these methods as long as there is a parent method in the call chain.

6. Run to Cursor (ALT+F9)-Always run to the cursor location.

7. Resume Program (F9)-runs until the next breakpoint is encountered.

8. View Backpoints (Ctrl + Shift +f8)-View all breakpoints you have set and can set some properties of breakpoints

9, Mute backpoints-All breakpoints are not set to an invalid state after selection. Click again to reset all breakpoints valid.

When you click the View Backpoints button, a Breakpoint Properties window appears, which allows you to make some more advanced settings for the breakpoint.

1. Lists the breakpoints set in all Programs

2, you can enter the condition, after the condition is established breakpoint only function (for example: Enter in the input box i = = 8), this conditional breakpoint in the actual development process is very useful. You can also set conditional breakpoints by right-clicking a breakpoint, such as:

All right, here's the debugging-related functionality.

Apply Packaged Signature Basics

In an Android Studio project, there will be multiple. gradle files. Where a build.gradle file exists in the project directory and a build.gradle file exists for each module.

The Build.gradle in engineering

buildscript {repositories {   jcenter()   // 声明使用 maven 仓库}dependencies {   // 依赖android提供的2.1.0-alpha5的gradle build  classpath ‘com.android.tools.build:gradle:2.1.0-alpha5‘}}// 为所有的工程的repositories配置为jcentersallprojects {repositories {jcenter()}}// 清楚工程的任务task clean(type: Delete) {delete rootProject.buildDir}

Build.gradle in the module

// 这表示该module是一个app moduleapply plugin: ‘com.android.application‘android {// 基于哪个版本编译compileSdkVersion 23// 基于哪个构建工具版本进行构建的buildToolsVersion "23.0.3"// 缺省配置主要包括:应用ID,最小SDK版本,目标SDK版本,应用版本号、应用版本名???????defaultConfig {    applicationId "open_open.com.helloworld"    minSdkVersion 10    targetSdkVersion 23    versionCode 1    versionName "1.0"}// buildTypes是构建类型,常用的有release和debug两种,可以在这里面启用混淆,启用zipAlign以及配置签名信息等。buildTypes {    release {        minifyEnabled false        proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘    }}}// dependencies它定义了该module需要依赖的jar,aar,jcenter库信息。dependencies {compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])testCompile ‘junit:junit:4.12‘compile ‘com.android.support:appcompat-v7:23.2.1‘}
Packaging signatures

Choose Build->generate signed APK ..., such as:

Keep Next in the pop-up window until the following interface:

In the absence of a key, we can first click on Create New ... button to create a key, the creation process is simple, such as:

If you already have a key, then click Choose Existing ... button to specify the location of the. jks file, such as:

Enter the key store password and key password (the two passwords you entered when you created the key) and click the Next button:

Next click on the Finish button and wait for the as package signature to complete, as will prompt us when the signature is complete:

Click on the show in Explorer to find our signature apk file:

Android Development Android Studio2.0 tutorial from Getting Started to mastering Windows Edition-Introductory 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.