Android Studio采用Gradle构建项目。项目中又两个build.gradle文件,一个在最外层的目录中,一个在app目录下。

最外层目录的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {    repositories {        google()        jcenter() //代码托管仓库    }    dependencies {        classpath "com.android.tools.build:gradle:4.0.0"  //构建Android项目,需要引用        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        google()        jcenter() //代码托管仓库    }}task clean(type: Delete) {    delete rootProject.buildDir}

app目录下的build.gradle

apply plugin: 'com.android.application' //应用程序模块(直接运行),还有一个值可选com.android.library库模块(依赖别的应用程序模块)android {  //android闭包,配置项目构建的各种属性。    compileSdkVersion 29    //项目的编译版本    buildToolsVersion "30.0.0"  //项目构建工具的版本    defaultConfig {                 //对项目更多细节配置        applicationId "com.et.helloworld"          //项目的包名,如果想要修改包名,直接在这修改        minSdkVersion 23            //项目最低兼容的Android系统版本        targetSdkVersion 29         //在目标版本上做过充分的测试,系统为应用程序启用一些最新的功能和特性。        versionCode 1               //项目版本号        versionName "1.0"           //项目的版本名。        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  //testInstrumentationRunner表明要使用AndroidJUnitRunner进行单元测试    }    buildTypes {    //用于指定生成安装文件的相关配置,两个包,一个是debug,一个是release。debug闭包用于指定生成测试版安装文件的配置。release用于生成正式版安装文件的配置。debug可以忽略不写。        release {            minifyEnabled false    //用于指定是否对项目的代码进行混淆            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'            //指定混淆时的规则文件。proguard-android-optimize.txt是Android SDK目录下的。proguard-rules.pro项目根目录下的。        }    }}dependencies { //指定当前项目所有的依赖关系。一共又三种依赖方式:本地依赖,库依赖,远程依赖。    implementation fileTree(dir: "libs", include: ["*.jar"])  //本地依赖声明,表示将libs目录下所有.jar后缀的文件都添加到项目构建路径中。    implementation 'androidx.appcompat:appcompat:1.1.0'    implementation 'com.google.android.material:material:1.1.0'    implementation 'androidx.annotation:annotation:1.1.0'    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'androidx.test.ext:junit:1.1.1'    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'}

更多相关文章

  1. undefined reference to '__android_log_print'(android studio1
  2. 读取android根目录下的文件或文件夹
  3. 在低版本Android上使用Material Design——AppCompat v21
  4. Android项目中如果json字符串中key-value顺序很重要,不要使用Andr
  5. Android选择本地视频文件
  6. 从J2EE转向Android的第九天-----文件存储

随机推荐

  1. 如何让百度收录我们自己的网站呢?
  2. vscode编辑器和插件安装及markdown语法熟
  3. SwiftUI - 百行代码变十行,Swift再创辉煌!
  4. Kubernetes 运维学习笔记
  5. Linux下smokeping网络监控环境部署记录
  6. Gitblit版本服务器环境部署记录
  7. Stimulsoft Reports如何进行数据连接?
  8. LVS+Keepalived 高可用环境部署记录(主主
  9. LVM常规操作记录梳理 [扩容、缩容、快照
  10. Centos下内网DNS主从环境部署记录