Common functions of Android Studio

Source: Internet
Author: User
Tags jcenter

Common functions of Android Studio

To simplify Android development, Google decided to focus on building Android Studio Tools. Google will stop supporting other integrated development environments such as Eclipse by the end of this year.

Android Studio is the first official Android development environment. Other tools, such as Eclipse, have been used on a large scale before Android Studio was released. To help developers turn to Android Studio, Google has written a set of Migration Guidelines.

For more information, see http://android-studio.org /.

This article describes common functions:

Introduction to the basic usage interface of Android Studio 1



This interface shows the function panels that we often encounter when using Android Studio.
  1. Project panel.
    Used to browse project files. The Project panel displays all current modules. The android application module displays a mobile phone icon (app in); the android library module displays a bookshelf icon (android-lib in ); the java library module displays a coffee icon (java-lib in ).
  2. Build the Variants panel.
    Used to set the Build Variants (Gradle knowledge) of the current project ). By default, all modules have two options: release and debug. When BuildTypes and productFlavors are added, more options (Gradle knowledge) will appear here ). By default, the difference between release and debug is not obvious; for code, there is no difference.
  3. Android panel.
    The function is similar to the Logcat in Eclipse, but it has some common functions, such as viewing system information.
  4. Editing area.
    Used to edit files.
  5. Gradle panel.
    Select the Gradle task list and double-click it to execute the Gradle task. Common Tasks: build, clean, assemble, assumerelease, assembleDebug, and lint.
    Tutorial 2

    Switch the Project view.

    The default Project panel displays the directory structure of Android. Click to switch.



    Common buttons 3

    1. Compile the module displayed in the module list on the right.
    2. The module list of the current project.
    3. Run the module displayed in the module list on the left.
    4. The module displayed in the module list on the left of debug.
    5. Attach debugger to Android process.
    6. .
    7. Project properties.
    8. Use Gradle to compile the project.
    9. Virtual Machine.
    10. SDK Manager.
    11. DDMS.
      Common panel 4



      Structure is used to display the Structure of the current active file. Supports not only Java files, but also Xml files,. properties configuration files, and other files.

      Tutorial 5



      When you view the layout file or the drawable Xml file, the Preview option is displayed on the right. Used to preview the effect.

      Tutorial 6



      Terminal panel. Function and command line, you can execute some command line commands here.

      Tutorial 7



      Memory Monitor is used to view the Memory usage of the app.

      Tutorial 8



      When your project uses version control, the Changes panel is displayed. Displays the list of files you modified for the local version library. By default, the modified file is displayed in blue, the new file is in blue, and the deleted file is in gray.

      The. gradle file briefly introduces multiple. gradle files in an Android Studio project. The project directory contains a build. gradle file and a settings. gradle file. Each module has a build. gradle file.

      This document briefly describes the content of the default. gradle file. For more information about Gradle Plugin, see here.

      {@ ProjectName} uild. gradle explanation 9

      buildscript {
      repositories {
      jcenter()
      }
      dependencies {
      classpath 'com.android.tools.build:gradle:1.0.0'
      }
      }

      allprojects {
      repositories {
      jcenter()
      }
      }



      The content of the build. gradle file in the default project directory is as follows.
      • Buildscript: the code used to set the driver for the build process.
      • Jcenter (): declare to use the maven repository. In the old version, mavenCentral () is used here ().
        1. MavenCentral (): indicates that the dependency is obtained from the Central Maven 2 repository.
        2. Jcenter (): indicates that the dependency is obtained from the Bintary's JCenter Maven repository. 3. ** mavenLocal () **: indicates that the dependency is obtained from the local Maven repository.
        3. Dependencies: Declares the version of the Android Studio gradle plug-in. Generally, you need to modify the following gradle version when upgrading the AS or importing a project generated from Eclipse. For the specific version ing relationship, click.
        4. Allprojects: Set the build process for each module. In this example, the maven repository dependency is set for each module.
          In Jingdezhen, the default maven source may not be accessible. You can set other maven sources in the following ways. Of course, you can also set the dependency on the local database.

          maven {
          url http://xx.xxx.xxx/xxx
          }



          Source Address of Open Source China:

          http://maven.oschina.net/content/groups/public/


          The source address of thirdparty in open source China is:

          http://maven.oschina.net/content/repositories/thirdparty/


          A project can have several databases. Gradle will search for them in each library according to the dependency definition sequence. If you find it in the first database, you will not find it in the second database.

          {@ ProjectName} settings. gradle 10

          include ':app'


          The content of the settings. gradle file in the default project directory is as follows. By default, the settings. gradle file in the project directory does not exist. You can create one by yourself.
          • Include ': app': indicates that the current project has a module named app.
            If one of your modules is not under the project root directory, you can set it like this.

            include ':app2'
            project(':app2').projectDir = new File('path/to/app2')



            {@ ModuleName} uild. gradle 11

            apply plugin: 'com.android.application'

            android {
            compileSdkVersion 21
            buildToolsVersion 21.1.2

            defaultConfig {
            applicationId cc.bb.aa.myapplication
            minSdkVersion 10
            targetSdkVersion 21
            versionCode 1
            versionName 1.0
            }
            buildTypes {
            release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
            }
            }

            dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            compile 'com.android.support:appcompat-v7:21.0.3'
            }



            The content of the build. gradle file in the default module Directory is as follows.
            • Apply plugin: 'com. android. application ':
              Com. android. application plug-in is used. That is to say, this is an android application module. Com. android. library indicates that this is an android library module.
            • Android:
              Configure parameters required for all android build processes.
            • CompileSdkVersion:
              The SDK version used for compilation.
            • BuildToolsVersion:
              Tool version used to compile the project in Gradle.
            • DefaultConfig:
              Default settings for Android projects.
              1. ApplicationId: application package name.
              2. MinSdkVersion: The minimum Android version is supported.
              3. TargetSdkVersion: Target version. It should be the Android version of the testing machine in the testing environment.
              4. VersionCode: version number. 5. ** versionName **: version name.
              5. BuildTypes:
                Compilation type. There are two default values: release and debug. We can add our own buildTypes here, which can be seen on the Build Variants panel (see tutorial 1 ).
                1. MinifyEnabled:
                  Whether to use obfuscation. The old version is runProguard, and the new version is renamed because the new version supports removing unused resource files, and the runProguard name is no longer appropriate. 2. ** proguardFiles **:
                  You can use multiple obfuscation files. In this example, the ** proguard-android.txt ** file in the ** SDK ** and the ** proguard-rules.pro ** file under the current ** module ** directory are used.
                2. Dependencies:
                  Used to prepare reference dependencies.
                  1. Compile fileTree (dir: 'libs', include: ['*. jar']):
                    Reference all. jar files in the libs folder under the current module Directory. 2. ** compile 'com. android. support: appcompat-v7: 21.0.3 '**:
                    REFERENCE The ** appcompat-v7 ** of the ** 21.0.3 ** version (that is, the commonly used ** v7 ** library Project ).
                    Version Control 12

                    After you create a project in Android Studio, there is no version control by default. If you want to control the version of the project, you can set it like this.
                    VCS --> Enable Version Control Integration.



                    If you want to cancel Version Control for a project, you can set it on the settings page.
                    In the list on the Right of Version Control, select the target module and click the minus sign on the right.



                    Tutorial 13

                    If you want to migrate a project from the version server, you can set it like this.
                    VCS --> Checkout from Version Control, select the Version Control tool of the server, and enter the address to move out.



                    You can also export data from the start page of Android Studio.
                    Click Checkout from Version Control, select the server Version Control tool, and enter the address to move out.


                     

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.