天天看点

Android Studio 内gradle的内部操作

Gradle文件是Android Studio相比于eclipse先进的地方,首先先查看一下gradle内部都包含什么代码吧:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.hxd.weatherforhxd"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:27.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}
           

一块一块的滤清都是干什么的

com.android.application

--->表示该项目为一个应用程序

com.android.library

--->表示项目为一个仓库,被应用程序进行依赖

compileSdkVersion 27

--->表示项目编译版本

applicationId "com.example.hxd.weatherforhxd"

--->项目的报名

minSdkVersion 19

--->最低兼容版本

versionCode 1

--->指定项目的版本号

versionName "1.0"

--->项目的版本名称

minifyEnabled false

--->表示代码发布时,是否进行混淆操作,进行ture反之为false

proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'、

--->指定混淆的规则

proguard-android.txt

--->表示Android系统下面的通用混淆规则

proguard-rules.pro

--->自己指定的混淆规则

dependencies

--->该闭包内为依赖内容

继续阅读