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
--->該閉包内為依賴内容