Android Studio Basic Usage

Source: Internet
Author: User

This article is original article, reprint please indicate source.

This article is mainly recommended for developers of Eclipse Development to use Android Studio (hereinafter referred to as: AS), introduce as the most basic and most commonly used functions, old drivers please bypass O (∩_∩) O, so as not to delay the precious time.

Main content:

(1) Environment construction

(2) New project (including module creation)

(3) Code obfuscation

(4) Common debugging function and application analysis related

(5) Pack apk

First, Environment construction (Windows)

(1) Install JDK, note as requirements JDK7 and later, installation process no longer repeat;

(2) as download, if for special reasons can not download the official website, please click here to download;

(3) as installation

1. Be careful to choose your own suitable installation location, such as:

2. If successful, step-by-step installation succeeds, the following interface appears:

3. First Run Configuration

4. If you can go to the As Start page, if the Android SDK download fails, please move the processing method written by this friend.

Ii. new project (including module creation)


(1) Create a project

Go to AS, upper left corner click File->new->new Project, as follows:

Enter the following interface:

Next:

Next:

Next:

Complete.

(2) Introduction to the main interface

(3) Preview

(4) Create module

For medium to large projects as a module (i.e., modules), the main ease of project layering and separation logic, so that the project logic clearer and easy project maintenance. Create the module as follows:

Go to the following page:

Go to the next step and complete the creation as follows:

For the creation and use of module, refer to my other article.

Second, code confusion

As projects are built and managed by Gradle, many of the information related to the application can be set here, as follows:

Code obfuscation in as is required to be set in the Build.gradle file and in the Proguard-rules.pro file (you can compare the effects before and after using the Jd-gui tool):

(1) Build.gradle file

Minifyenabled: Indicates whether to turn on confusion, default to False

Proguardfiles: Confusing configuration files, typically using the default Proguard-rules.pro file in your project.

(2) Proguard-rules.pro file

Confusing setting, refer to Progurad official website for details.

Note that the red-framed part of the figure, because all jar packages (where the jar package is confusing for example, app obfuscation is similar) requires an external interface (the module without external interface is generally meaningless), there are several ways to set up the external interface class:

A:-keep public class *, for example:

-keep public class * {
public protected *;
}

B: as shown.

Because a module generally has a lot of class files, when we want to confuse the class name of all other class files except the external interface class, we can create a single base class or interface, and let the external interface class inherit the base class or interface.

C:-keep public class XXX, specific classes are not confused, for example:

-keep public class xiaoshubao.player.userlogin{
public protected *;
}

Four, the commonly used debugging function and the application analysis correlation

(1) Creating the emulator (omission of the creation process)

(2) Run simulator

(3) Application analysis related

1. Log output as shown in.

2. Memory Analysis

A:

B:

C:

D: Memory Information acquisition

E: Analysis of memory leaks using Memoryanalyzer (MAT)

First, it is not available to import the Hprof file generated directly from the previous step into the mat tool, and there are two ways to convert it:

    • Method One:

    • Method Two: The Hprof-conv tool is converted and then imported into the Mat tool, and the Hprof-conv tool is in the Platform-tools directory under the Android SDK, as follows:

Copy the Snapshot_2016.07.20_21.52.57.hprof file to the e:/1/folder, cmd to the Hprof-conv.exe directory, and execute the conversion command, as follows:

Generate the target 3.hprof file as follows:

In the mat, import the converted Hprof file as follows:

The CPU, GPU and other tabs are no longer mentioned, you can do their own research.

Five, packaging apk

Build->generate signed APK

The following interface appears:

(1) Create a new JKS signature file, as follows:

(2) Select an existing JKs file

(3) Here we demonstrate the creation of a new JKS signature file, as follows:

Click OK and the following screen appears:

Click Next, as follows:

Click Finish to successfully generate the APK file with our own signature:

In the future when the new version of the app can be signed with the JKs file just generated, note that the new version of the same app signature file must be the same as the old version of the signature file, multiple apps can share the same signature file, the reason is not much to say.

Summary, This article mainly explains uses as creates the project, the debugging project, publishes the most basic use, along with the familiarity degree enhancement everybody can own in-depth research, for example Gradle constructs, the memory analysis and so on.

Android Studio Basic Usage

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.