【生意多】-免费发布分类信息
当前位置: 首页 » 新闻 » 教程 » 操作系统 » 正文

第二行代码pdf下载(第一行代码第二版pdf百度云)

放大字体  缩小字体 发布日期:2022-06-30 20:52:37    浏览次数:5

不同于Eclipse,Android Studio是采用Gradle来构建项目的。Gradle是一个非常先进的项目构建工具,它使用了一种基于Groovy的领域特定语言(DSL)来声明项目设置。
首先看项目最外层目录下的build.gradle文件,代码如下所示:
~~~
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
~~~
这些代码是自动生成的,
首先两处,repositories的闭包中都声明了jcenter()这个配置。jcenter是一个代码托管仓库。
接下来,dependencies闭包中使用classpath声明一个Gradle插件。因为Gradle并不是专门为构建Android项目而开发的,因此如果我们要想使用它来构建Android项目,则需要声明com.android.tools.build:gradle:3.1.3这个插件。其中最后面的部分是版本号。

下面我们来看app目录下的build.gradle文件,代码如下所示:
~~~
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.0'
defaultConfig {
applicationId "com.lowthink.helloworld"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test

 
(文/小编)
打赏
免责声明
• 
本文为小编原创作品,作者: 小编。欢迎转载,转载请注明原文出处:https://www.31duo.com/news/show-3574774.html 。本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们。
 

(c)2016-2019 31DUO.COM All Rights Reserved浙ICP备19001410号-4

浙ICP备19001410号-4