Andorid Studio 中的.gradle

来源:互联网 发布:腾讯大数据 会 11.22 编辑:程序博客网 时间:2024/06/01 18:54

使用Android Studio 新建的项目中有三个.gradle文件,如下:

1)  ./build.gradle //比较基础的配置 

// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {    //声明中央仓库的源,这里可以看到是指明的jcenter(), 之前版本则是mavenCentral()    repositories {        jcenter()    }    //android gradle 插件的版本,必须要视Android Studio和SDK版本而定。    //开发过程中就出现了"You must use a newer version of the Android Gradle plugin..."    //这时候最简单的方式就是将版本后面添加一个"+"    dependencies {        classpath 'com.android.tools.build:gradle:1.3.0+'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}

2) ./setting.gradle  //声明一些需要加入gradle的module

//由于只是新建的一个项目中间就一个moduleinclude ':app'

3) ./app/build.gradle  //针对此app更细致的配置

<pre name="code" class="html">// 声明是Android程序apply plugin: 'com.android.application'android {    // 编译SDK的版本    compileSdkVersion 23    // build tools的版本    // (需要与本地安装版本匹配,很多人导入新的第三方库,失败的原因之一是版本不对,可以通过SDK Manager下载和查看)    buildToolsVersion "23.0.0"    defaultConfig {        // 应用的包名        applicationId "xx.xx.xx"        minSdkVersion 14        targetSdkVersion 22        versionCode 310        versionName "3.0.1"    }    buildTypes {        release {            // 是否进行混淆            minifyEnabled false            // 混淆文件的位置            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }}dependencies {    // 编译libs目录下的所有jar包    compile fileTree(dir: 'libs', include: ['*.jar'])    testCompile 'junit:junit:4.12'    compile 'com.android.support:appcompat-v7:23.0.0'}

以上文件里的内容只是基本配置的学习,其实还有很多自定义部分,如自动签名,多渠道打包等,后续会继续分享。


0 0
原创粉丝点击