) Android learning notes ② -- basic knowledge of creating HelloWorld, androidhelloworld

Source: Internet
Author: User
Tags jcenter

(GO) Android learning notes ② -- basic knowledge of creating HelloWorld, androidhelloworld
Develop the first application

Can I develop my own applications? Okay! Let's Start. First click Start a new Android Studio Project to create a Project:

Next, enter the application name (the first letter must be in uppercase), the Company domain, and the specified application storage directory. Click Next to go to the Next step:

If the first letter is not in uppercase, the following message is displayed:The application name for most app begins with an uppercase letter

Next, you need to select the devices (such as "mobile phones and tablets", "Wear", "TV", and "Android Auto") to be developed, and determine the minimum SDK version.

The role of the Minimum SDK is to verify the Android version of the device before the application is installed. If the Android version of the device is earlier than the Minimum version, the user is prevented from installing the application.


If you do not know how to select the minimum version, click Help me choose to view the distribution chart and description of each version:

Click the Next button to proceed to the Next step. Because we have not installed the SDK version 2.3.3, Android Studio will automatically download the required components. This process may be slow.

Next, we need to select the style of our first Activity through an image-friendly GUI template:

Then you need to name the Activity and Layout.

After you click Finish, Android Studio starts to create and compile the application.

After compilation, we can see the IDE interface of Android Studio.

From the figure, we can see that Android Studio has helped us organize the project very well.

Interface Introduction


As shown in, the interface is divided into five areas for detailed explanation:

Area 1


This area is related to debugging.

1. Compile the modules displayed in 2

2. List of modules of the current project

3. Run the module displayed in step 2.

4. debug the modules displayed in 2

5. module code coverage shown in Test 2

6. debug the processes running on Android

7. Run the module displayed in step 2 again.

8. Stop running the module displayed in 2.

Area 2


This area is mainly related to Android devices and virtual machines.

1. Synchronize the Gradle file of the project. It is usually required when the Gradle configuration is modified.

2. Virtual device management

3. Android SDK Management

4. Android device monitoring

5. Genymontion simulator (install the Genymontion plug-in. Install [simulator installation)

Area 3


This area mainly involves operations related to project file resources.

1. display the file organization mode in the Project. The default mode is Android. You can select "Project, Packages, Scratches, ProjectFiles, Problems ..." . Android and Project are the most commonly used.

2. Locate the currently opened file in the project directory.

3. Close all expansion items in the project directory.

4. Some additional system configurations. Click it and a pop-up menu is displayed:

After Autoscroll to Source and Autoscroll from Source are selected, Android Studio automatically locates the current edited file in the project. You can explore other functions by yourself.

Area 4


This area is mainly used to write code and design layout.

1. The Tab page of the opened file. (On the Tab page, press the Cmd key + click the mouse. A pop-up menu will be displayed, which will surprise you !)

2. UI layout preview area.

3. Switch the layout editing mode. For some old birds, they prefer to use Text to edit the layout. New users can try designing to edit the layout and then switch to the Text mode, it is helpful for learning about Android layout design.

Area 5


This area is mostly used to view some output information.

1. Terminal-partners who like command line operations do not need to start additional terminals.

2. Information-some output information of Project compilation.

3. Monitoring: You can view some output information of an application.

4. Run-related information after the application runs.

5. TODO-a list marked with a TOTO annotation.

6. Events-some event logs.

7. On the Gradle console, you can learn some output information when using Gradle to build an application.

Android Studio directory structure

1. Gradle compilation system. The version is specified by wrapper.

2. files required by Android Studio IDE

3. storage directory of application-Related Files

4. Related Files generated after compilation

5. Store related dependent Libraries

6. Code storage directory

7. Resource file storage directory (including layout, images, styles, and so on)

8. A list of basic information about the application and describe which components exist.

9. git Version Management ignores files and marks which files do not need to enter the git library.

10. Android Studio project files

11. gradle configuration of the module

12. code obfuscation Rule Configuration

13. gradle configuration of the project

14. gradle-related global attribute settings

15. Local attribute settings (key setting, android sdk location, and other attributes)

 

Application Development debugging


As shown in 1, click Set breakpoint at the line number to be debugged, and then click the Debug button (or press Ctrl + D) as shown in 2 to start debugging.

As shown in, the debugging view is displayed below Android Studio.

1. Code lines of the current program

2. debugging related buttons

3. In the program call stack area, all methods that have been called by the program to the breakpoint are displayed. The earlier the following method is called.

4. Local variable observation area

5. User-Defined variable observation area

1. step over (F8)-the Program executes a row down. If there is a method call in the current row, the method is returned after the execution is completed, and then to the next row.

2. step into (F7)-the Program executes a row down. If the current row has a user-defined method (unofficial class library method) call, this method is entered.

3. Force step into (Alt + Shift + F7)-the Program executes a row down. If the current row has a method call, this method is entered.

4. step out (Shift + F8)-If you enter a method during debugging and feel that the method is correct, you can use step out to jump out of the method, returns the next line of statements called by the method. It is worth noting that this method has been executed.

5. After Drop Frame-click this button, you will return to the call of the current method for re-execution, and the value of all context variables will return to that time. As long as there is a higher-level method in the call chain, you can jump to any of the methods.

6. Run to cursor (Alt + F9)-always Run to the cursor position.

7. Resume Program (Alt + Cmd + R)-runs the Program until the next breakpoint is reached.

8. View Backpoints (Shift + Cmd + F8)-View all breakpoints you have set and set the attributes of breakpoints


1. List the breakpoints set in all programs

2. You can enter a condition. A breakpoint takes effect after the condition is set up (for example, enter I = 8 in the input box). This breakpoint with a condition is very useful in actual development. You can also right-click a breakpoint to set a conditional breakpoint, for example:

9. Mute Backpoints-do not set the selected breakpoints to invalid. Click again to reset all breakpoints.

Now we have finished debugging.

Application packaging signature Basics

Multiple. gradle files exist in an Android Studio project. A build. gradle file exists in the project directory and each module has a build. gradle file.

  • Build. gradle in the project
    Buildscript {repositories {jcenter () // declare to use maven repository} dependencies {// dependent on gradle build classpath 'com of 2.1.0-alpha5 provided by android. android. tools. build: gradle: 2.1.0-alpha5 '} // configure the repositories for all projects as jcentersallprojects {repositories {jcenter () }}// clear the project task clean (type: delete) {delete rootProject. buildDir}
  • Build. gradle in the module
    Build in the module. gradle // This indicates that the module is an app moduleapply plugin: 'com. android. application 'android {// based on which version compileSdkVersion 23 // based on which build tool Version buildToolsVersion "23.0.3" // default configuration mainly includes: application ID, minimum SDK version, target SDK version. The application version number and application version name defaultConfig {applicationId "open_open.com.helloworld" minSdkVersion 10 targetSdkVersion 23 versionCode 1 versionName "1.0"} // buildTypes is the build type, commonly used are release and debug. You can enable obfuscation, zipAlign, and signature configuration. Information. BuildTypes {release {minifyEnabled false proguardFiles upload'), 'proguard-rules. PROs' }}// dependencies it defines the jar, aar, and jcenter library information that the module depends on. Dependencies {compile fileTree (dir: 'libs', include :['*. jar ']) testCompile 'junit: junit: 4.12 'compile 'com. android. support: appcompat-v7: 23.2.1 '}

     

Package Signature

Select Build-> Generate Signed APK..., for example:

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

If no Key exists, you can click Create new... to Create a Key. The creation process is simple, for example:

If you already have a Key, click the Choose existing... button to specify the location of the. jks file, for example:

Enter the Key store password and Key password (the two passwords entered during Key creation), and click the Next button:

Next, click the Finish button and wait until the AS package signature is complete. After the signature is complete, the AS will prompt us:

Click Revaal in Finder to find the signed APK file:

 

 

This article

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.