Android Studio installation configuration, Environment setup detailed steps and basic use, android installation Configuration

Source: Internet
Author: User
Tags version control system

Android Studio installation configuration, Environment setup detailed steps and basic use, android installation Configuration
Preface

The installation, configuration, and usage of Android Studio are coming ~

Not to mention, the following describes how to install and configure JDK (and its environment variables are configured in the Java Development Environment) and Android Studio, the basic usage of projects, subject font replacement, window tools, la S, shortcuts, and so on are described one by one.

 

Install java

Download Java installation package (jdk, there are a lot of online, it is best to go to the official website: https://www.java.com/zh_CN/), after installation remember to configure environment variables;

 

    • Create a new variable named JAVA_HOME in "system variables". The variable value is your local java installation directory. Here I am: C: \ Program Files \ Java \ jdk1.7.0 _ 80, this setting is used as a reference to the following two environment variables.

    • In the "System variables" option area, check the PATH variable. If it does not exist, create a new variable PATH. Otherwise, select the variable and click "edit, add "% JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin;" to the start position of the variable value text box ;"

    • Check the CLASSPATH variable in the "System variables" option area. If the CLASSPATH variable does not exist, create the CLASSPATH variable. Otherwise, select the variable and click "edit, add "." To the start position of the variable value text box. % JAVA_HOME % \ lib \ dt. jar; % JAVA_HOME % \ lib \ tools. jar ;".

Method for Determining successful installation:

 

Run the following commands: "java-version", "java", and "javac". If an image is displayed, the environment variable is successfully configured;

Note:

 

    • JAVA_HOME: the value of this environment variable is the directory where Java is located. Some Java software and some Java tools need to use this variable. When setting PATH and CLASSPATH, you can also use this variable for easy setting.

    • PATH: Specifies a PATH list for searching executable files. When executing an executable file, if the file cannot be found in the current PATH, find each PATH in the PATH in sequence until it is found. Or if the PATH in the PATH cannot be found, an error is returned. Java compilation commands (javac), execution commands (java), and some tool commands (javadoc, jdb, etc.) are all in the bin directory under the installation path. Therefore, we should add this PATH to the PATH variable.

    • CLASSPATH: Specifies a path list, which is used to search for Classes required for Java compilation or running. In addition to paths, the CLASSPATH list can also contain. jar files. The. jar file is used as a directory to search for classes in Java. Generally, we need to include jre/lib/rt. jar (Linux: jre/lib/rt. jar) in the JDK installation path in CLASSPATH.

    • PATH and CLASSPATH both specify the PATH list. The items in the list (that is, each PATH) are separated by separators. In Windows, the Delimiter is a semicolon (;), while in Linux, The Delimiter is a colon (:).

    • Note that the CLASSPATH contains a "Current Directory (.)". After the directory is included, you can go to any directory and execute Java programs that need to use a class in the directory, even if the path is not included in the CLASSPATH. The reason is simple: although the path is not explicitly included in CLASSPATH, "." In CLASSPATH represents the path.

Download and install the Android SDK

If an Android SDK of the appropriate version already exists locally, you do not need to download it again, or you can use SDK Manager to update the SDK;

If no SDK is available, you need to download it.

Here we will use SDK Manager to download/update the SDK:

(1) If the SDK Manager is not installed, download and install it;

Go to the installation directory:

(2) Start the SDK Manager.exe, for example:

(3) If the update takes a long time or cannot be updated, you must configure a proxy.

 

Download and install Android Studio (New Project Creation and debugging)

Provide a domestic image https://github.com/inferjay/AndroidDevTools

After the download, if the package is installed, you can directly install it. If the package is decompressed, You can decompress the package and run it directly (the studio.exe file under the installation directory ).

During the installation process, because the SDK has been downloaded before, you can skip the SDK installation and keep going to "finish", run "Open Android studio", configure the SDK manually, and click "SDK Manager, configure the path of the downloaded SDK, for example:

After configuring the SDK, you can create a project, as shown in the following series:

(1) file --> new Project:

(2) next --> you can select the version of the created Project --> if you do not know the version, click help me choose:

 

(3) Click help me choose to display information about the current Android system versions. What else is unknown! (It's great to look at the UI)

(4) Select the version and click next --> to go to the main Activity style selection page. The following lists several types of styles:

(5) continue next --> until finish, the project is created, and the creation process will be a little longer, so you have to wait.

(6) The following is the created Project interface. Click the run icon in the toolbar above to run the project. The logcat below contains the log information, which is similar to Eclipse and will be easy to use, it will not be described too much.

Later, I will introduce in detail the differences between Android Studio and Eclipse and their unique advantages.

 

Android Studio project directory structure

The default directory structure of a new project is as follows:

It can be seen that there is a big difference between the directory structure of Eclipse and Android Studio. A window of Android Studio can only have one project, while Eclipse can have many projects at the same time, if you are not used to it, you can click the Android robot in the upper left corner to switch:

After switching "Android" to "Project", see:

It seems that this is similar to the structure in Eclipse.

In general, the differences with Eclipse are as follows:

1. Android Studio has the concept of Project and Module. As mentioned above, a window in Android Studio can only have one Project, that is, one Project, representing one workspace, but one Project can contain multiple modules, for example, the Android Library and Java Library referenced by your project can be regarded as a Module;

2. In the preceding directory, java code and resource files (images, layout files, etc.) are all attributed to src, and there is a main group under the src directory, the java and res folders are divided at the same time. The java folder is equivalent to the src folder under Eclipse, and the res directory structure is the same.

You only need to use the directory structure of the project as long as you are used to it. Let's talk about other usage of Android Studio.

3. Main files and directories:

(1) settings. gradle: Every Moudle must be registered here. You can open this file and you will understand it;

(2) build. gradle: configuration of each Project

(3) app: Each Module

(4) app/build. gradle: Each Module configuration file, such as the dependent class library and SDK version

(5) app/src/: Both source code and resource files are here; all files we write are here.

(6) app/libs/: Add a class library.

 

Basic use of Android Studio

Android Studio is easy to use because it is easier to use in many places than Eclipse. See the following:

1. Android Studio does not need to be manually saved. It has the Automatic save function;

2. The "TODO" view shows the position of the current program;

3. the Android Monitor view contains interfaces such as Logcat and Memory, which are convenient to use;

4. Compared with Eclipse, Android Studio has its own "Terminal" feature, which is much easier for Android Developers to use than simply opening a cmd;

5. There are several common functions on the right of the Studio menu bar, including Gradle synchronization, AVD Manager, SDK Manager, and DDMS:

(1) When performing Gradle synchronization in your project or changing the Gradle configuration, click this button to download the corresponding dependency.

(2) AVD Manager simulator Management

(3) SDK Manager is responsible for your SDK version.

(4) DDMS is the Dalvik Debug Monitor Service and Dalvik Debug Monitoring Service.

 

 

Common shortcuts for Android Studio

Global shortcuts (important)

 

Shortcut Keys in Eclipse

ALT + ENTER

Quick engineering repair

CTRL + 1

CTRL + SHIFT +

Quick Search

 

CTRL + ALT + L

Format code

CTRL + I

CTRL + Q

View document

Automatic mouse

SHIFT + ESC

When you switch to a non-editing area, disable the area and return to the editing area.

 

 

Editing area shortcut

 

CTRL + B/F4

Or Ctrl + Click (applicable)

View Source Code

ALT + INSERT

Insert method (constructor, Get Set method, etc.), create a file in the project structure

   

ATRL +/

Contextual Association

ALT + LEFT/RIGHT

Switch between different documents

ALT + TOP/BOTTOM

Jump to the previous/next Method

 

Note

 

CTRL +/

View current row

CTRL + SHIFT +/

Document comment

 

Copy/paste

 

Shortcut Keys in Eclipse

CTRL + C

Copy this row

 

CTRL + V

Paste

 

CTRL + X

Cut

 

CTRL + Y

Delete this row

CTRL + D

 

Search

 

Ctrl + Shift +

Search for all actions

Ctrl + F

Search for the currently edited document

Ctrl + R

Search and replace

Ctrl + N

Search class)

Ctrl + SHIFT + N

Search for files

 

Android Studio VS Eclipse

I believe that there are still a majority of Eclipse products in China. First of all, let's take a look at some of the advantages of maxcompute Studio, which is more convincing to explain why we need to migrate from Eclipse to maxcompute Studio.

1. Launched by Google

There is no doubt that this is its biggest advantage. Android Stuido was launched by Google and specifically tailored for Android. It is an IDE that Google strongly supports based on IntelliJ IDEA transformation, this should explain why it is the future of Android.

2. Faster

The startup speed, response speed, and memory usage of Eclipse have been criticized. I believe you should have a deep understanding of this and often encounter stuck state. Studio is fully ahead of Eclipse in any aspect.

3. More beautiful UI

The black theme demonstrated on I/O is amazing. The cool black interface of the Darcula theme comes with Stuido, the black subject in Eclipse is too low.

4. More intelligent

Note completion is of great significance for development. Studio is more intelligent and intelligently saved, So you no longer need to Ctrl + S every time. After you are familiar with Studio, the efficiency will be greatly improved.

5. Integrated Gradle build tools

Gradle is a new build tool. It supports Gradle since the appearance of Studio. It can be said that Gradle integrates Ant and Maven advantages, both of which are great in configuration, compilation, and packaging.

6. Powerful UI Editor

The editor of Android Studio is very intelligent. In addition to absorbing the advantages of Eclipse + ADT, it also comes with real-time previewing of multiple devices, which is an artifact for Android Developers.

7. built-in terminal

Studio built-in terminal, which is a good news for those who are used to command line operations. They no longer have to switch back and forth. One Studio can do it all.

8. Improved plug-in system

Maxcompute Studio supports various plug-ins, such as Git, Markdown, and Gradle. You can search for and download any plug-ins you want.

9. Perfect Integration of Version Control System

During installation, popular version control systems such as GitHub, Git, and SVN are provided. You can check your project directly.

 

Switch the Android project to Android Studio

Google provides two solutions.

First

Directly select the directory, and next until the end, our Eclipse project is on Android Studio. Note that the imported project will retain the Eclipse build method, for example, if we use Ant to build on Eclipse, it will still be built with Ant after migration.

Second

First, export the project as a Gradle project in Eclipse.

 

 

Select Export

Export the Gradle Project

Then open build. grade in Android Studio.
In this way, the project becomes a Gradle build.

 

Additional instructions

1. the SDK directory cannot contain spaces;

2. Recommended settings: Case Insensitive settings, automatic package import settings, Git directory settings, and eclipse shortcut style;

3. The menu font size is 13, and the code font size is 15.

4. the shortcut key may be occupied by other programs. In particular, the intel graphics program occupies the ctrl + alt + down arrow. disabling the program is also invalid. You need to change the shortcut key and then disable it. After occupying the key, this will take effect in studio. We recommend that you download a hotkey conflict detection tool.

5. import the eclipse file: If eclipse is used, new-import module is generally used, because the studio project corresponds to the eclipse workspaces, and the import project is to import a workspaces, the basic option is unavailable.

6. Import the studio file: Use the open button directly to check whether the gradle and build tools versions are set. Otherwise, the corresponding build tools will be automatically downloaded when the open tool is enabled. If FQ is not enabled, the tool will be stuck, you can try to modify the file before opening it.

7. environment variable configuration: add the tools and platform-tools sub-directories under the SDK directory to the path environment variable of the system.

8. Go to the sdk directory and run sdk manager to download sdks of other versions.

9. The environment variable ANDROID_SDK_HOME refers to the default installation path of the virtual device, which is stored on the drive C by default and takes up a large amount of space. If you need to specify a directory, you need to set a path for this environment variable.

10. The installation path must be in English and do not use Chinese characters.

11. environment variables are divided into system variables and user variables. The difference is that the first one is system-level for all users, and the last one is for the current user only.

 

 

 

Original works can be reprinted. During reprinting, you must mark the original source, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://wangzhaoli.blog.51cto.com/7607113/1730011

 

 

 

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.