Android - Gradle系列文章

 

Gradle 是一种多用途的构建工具. 它可以在你的构建脚本里构建任何你想要实现的东西,类似Linux下的make;

 

【参考来源:http://code.tutsplus.com/tutorials/the-ins-and-outs-of-gradle--cms-22978】

buildscript {
 
//Project-level Gradle build files use buildscript to define dependencies.//
 
    repositories {
 
        jcenter()
    }
 
//This file relies on the jJCenter repository.//
 
    dependencies {
 
   classpath 'com.android.tools.build:gradle:1.0.0'
 
//Project is dependent on version 1.0.0 of the Android plugin for Gradle.// 
 
    }
}
 
allprojects {
 
//Defines the dependencies required by your application.//
 
    repositories {
        jcenter()
    }
}
 
//Application depends on the jCenter repository.//
apply plugin: 'com.android.application'
 
//Since this project is an Android app, the build.gradle file utilises the Android plugin.//
 
android {
 
//The following section configures all your project’s Android-specific parameters, 
//and tells Gradle which version of Android it should build your project with.
//If you’ve developed Android applications before, the following should all be familiar.// compileSdkVersion 21 //The API your project is targeting.// buildToolsVersion "21.1.1" ////The version of the build tools you want to use.// defaultConfig { applicationId "com.example.jessica.myapplication" //Defines your application’s ID. Note, earlier versions of the Android plugin used ‘packageName’ instead of ‘applicationID.’// minSdkVersion 16 //The minimum API required by your project.// targetSdkVersion 21 //The version of Android you’re developing your application for.// versionCode 1 versionName "1.0" } buildTypes { release { //‘BuildTypes’ controls how your app is built and packaged. If you want to create your own build variants, you’ll need to add them to this section.// minifyEnabled true //Gradle runs ProGuard during the build process.// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' //Applies the default ProGuard settings from the Android SDK.// } } } dependencies { //Declares the dependencies for the current module.// compile fileTree(dir: 'libs', include: ['*.jar']) //Although you can add JAR files by compiling them individually, this can be time-consuming if you have lots of JARs.
//In this example, we’re telling Gradle to add all the JAR files in the app/libs folder.// compile 'com.android.support:appcompat-v7:21.0.3' //To create more dependencies, add them to the depencies closure.// }

This file allows other people to build your code, even if they don't have Gradle installed on their machine.

This file checks whether the correct version of Gradle is installed and downloads the necessary version if necessary.

In our sample app, gradle-wrapper.properties contains the following:

distributionBase=GRADLE_USER_HOME
 
//Determines whether the unpacked wrapper distribution should be stored in the project, or in the Gradle user home directory.//
 
distributionPath=wrapper/dists
 
//The path where the Gradle distributions required by the wrapper are unzipped.//
 
zipStoreBase=GRADLE_USER_HOME
 
zipStorePath=wrapper/dists
 
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
 
//The URL where the correct version of Gradle should be downloaded from.//

 

http://tools.android.com/tech-docs/new-build-system/user-guide

  0、Gradle 插件 官方文档 

 

http://stormzhang.com/android/2016/07/02/gradle-for-android-beginners/

  0、给 Android 初学者的 Gradle 知识普及

  

http://stormzhang.com/devtools/2015/06/17/android-studio-all/

  1、Gradle基础

  2、Gradle命令详解与导入第三方包

  3、Gradle多渠道打包

 

http://stormzhang.com/android/2016/03/13/gradle-config/

  4、Gradle依赖的统一管理

 

http://stormzhang.com/android/2014/02/28/android-gradle/

  5、Gradle介绍

 

https://www.gitbook.com/@dongchuan

  6、Gradle User Guide 中文版

 

http://avatarqing.github.io/Gradle-Plugin-User-Guide-Chinese-Verision/

  7、Gradle Android插件使用指南中文版

 

 http://stormzhang.com/android/2015/01/25/gradle-build-field/

  8、Gradle自定义你的BuildConfig

 

http://stormzhang.com/android/2015/03/01/android-reference-local-aar/

  9、Android模块化编程之引用本地的aar

 

  10、Gradle build生成签名APK

android {

    signingConfigs {
        release {
            storeFile file("myrelease.keystore")
            storePassword "********"
            keyAlias "******"
            keyPassword "******"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

  

posted @ 2016-05-07 20:27  chenyizh  阅读(171)  评论(0)    收藏  举报