Yvonne1206

导航

Android Studio学习之build.gradle文件

参考书籍:第一行代码

最外层目录下的build.gradle

buildscript{
repositories{ jcenter()
//代码托管仓库 } dependencies{ classpath 'com.android.tools.build:gradle:2.2.0' //声明Gradle插件//版本 } } allprojects{ repositories{ jcenter() } }

 

    

app目录下的build.gradle
apply plugin: 'com.android.application'      //应用程序模块   com.android.library库模块

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.example.helloworld"         //项目包名
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"    //细节配置
    }
    buildTypes {
        release {
            minifyEnabled false   //进行混淆否?
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                'proguard-rules.pro'
        }
//debug包可忽略 } } dependencies { compile fileTree(dir:
'libs', include: ['*.jar']) //本地依赖 compile 'com.android.support:appcompat-v7:24.2.1' //远程依赖 testCompile 'junit:junit:4.12'              //声明测试用例库 }

 

-------------------------------------------------

本地依赖:对本地的Jar包或目录添加依赖关系

compile fileTree()

库依赖:  对项目中的库模块添加依赖关系

compile project()

远程依赖:对jcenter库上的开源项目添加依赖关系

compile ' '

posted on 2018-03-06 20:57  Yvonne1206  阅读(180)  评论(0)    收藏  举报