Since the launch of Android Studio at the Google I/O conference in 13, I've shifted my development work from Eclipse to Android studio, and I've been increasingly out of the reach of the senile eclipse. In comparison, Android studio has blown eclipse from the support of running speed and Android development, the former technology-sensitive UI is a strong grasp of my heart! :)
Say not much, first on a bunker:
Android Studio defaults to Gradle compilation project; Gradle based on the groovy language, groovy is a dynamic language running on the JVM, similar in syntax to Java, and can reference Java code in a groovy project This makes it easy for Java programmers to customize Gradle compilation logic.
Let's look at Gradle's file structure first:
Settings.gradle for the entire project (Androidstudiosample):
1 include ': App ', ': library '
Build.gradle for the entire project (Androidstudiosample):
// top-level build file where can add configuration options common to all sub-projects/modules. Buildscript { repositories { mavencentral () } dependencies { ' com.android.tools.build:gradle:0.10.+ ' // Note:do not place your application dependencies here; they Belong // in the individual module build.gradle files }}allprojects { repositories { mavencentral () }}
The build.gradle of the main Moudle (APP)
1Apply plugin: ' Android '2 3 Android {4Compilesdkversion 195Buildtoolsversion "19.1.0"6 7 Defaultconfig {8PackageName "Com.baron.android.app"9Minsdkversion 9TenTargetsdkversion 19 OneVersioncode 1 AVersionname "1.0" - } - Buildtypes { the Release { -Runproguardfalse -Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro ' - } + } - } + A Dependencies { atCompile Filetree (dir: ' Libs ', include: [' *.jar ']) -Compile ' com.android.support:appcompat-v7:19.1.0 ' -Compile ' com.android.support:support-v4:19.1.0 ' -Compile ' com.android.support:appcompat-v7:19.1.0 ' -Compile ' com.android.support:support-v4:19.1.0 ' -Compile ' com.android.support:appcompat-v7:19.+ ' in}
Build.gradle of Submodule (library):
Apply plugin: ' Android-library 'Android {compilesdkversion19buildtoolsversion"19.1.0"Defaultconfig {PackageName"Com.baron.android.library"minsdkversion8targetsdkversion19Versioncode1Versionname"1.0"} buildtypes {release {Runproguardfalseproguardfiles Getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro '}}}dependencies {compile Filetree (dir:' Libs ', include: [' *.jar ']) Compile' com.android.support:appcompat-v7:19.+ 'Compile' com.android.support:appcompat-v7:19.+ '}
The above is a basic settings.gradle and Build.gradle file in project.
Settings.gradle files include ': App ', ': library ' indicates androidstudiosample This project contains the app and library two module;
Build.gradle is mainly divided into four parts: Apply plugin, Buildscript, Android and dependencies;
1, apply plugin indicates the use of plug-ins, apply plugin: "Android" indicates that this is an Android project, apply plugin: "Android-library" indicates that this is an Android Lib project;
2, buildscript{...} This piece of content defines the compilation environment, such as the dependent gradle version, etc.;
3, android{...} This section defines the project parameters, such as package name, version number, SDK version, Buildtypes, Signingconfigs, Productflavors, and so on;
4, dependencies{...} A dependency is defined.
First of all, there are three main types of dependencies that we commonly rely on:
1 dependencies { Span style= "Color:rgb (0, 128, 128); >2 Compile Filetree (dir: ' Libs ', include: [' *.jar ' 4 compile ' com.android.support:support-v4:19.1.0 ' 5 compile ' com.android.support:appcompat-v7:19.1.0 ' 6 Compil E ' com.android.support:support-v4:19.1.0 ' 7 compile ' com.android.support:appcompat-v7:19.+ ' 9 }
All right, let's write about this today, and then continue:)