先来看一下最外层目录下的 build.gradle 文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
jcenter() 是一个代码托管仓库,很多 Android 开源项目都会选择将代码托管到jcenter上,声明了这行配置之后,我们就可以在项目中轻松引用任何 jcenter 上的开源项目啦O(∩_∩)O~。
dependencies 中使用 classpath 声明了一个 Gradle 插件。
下面我们再来看一下 app 目录下的 build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.example.deniro.myapplication"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}
第一行应用了一个插件,一般有两种值可选:com.android.application 表示这是一个应用程序模块,com.android.library 表示这是一个库模块。应用程序模块和库模块的最大区别在于,一个是可以直接运行的,一个只能作为代码库依附于别的应用程序模块来运行。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shouji/article-76464-6.html
你以为是小学的数学题
这个弱智外星人日本狗的奴才迟早死得凄惨