1. Android项目的文件

  1. 工程目录下的build.gradle文件作用:指定代码托管仓库、指定构建项目的对应的gradle插件和版本等,因为gradle不光可以用于构建Android项目,还可以构建JavaC++项目,例如我们开发的安卓项目一般是:

    buildscript {
        repositories {
            google()
            jcenter()
            // 代码托管仓库,例如Jcenter、maven中央仓库
        }
        dependencies {
            // 项目对应的构建工具和版本
            classpath 'com.android.tools.build:gradle:3.5.2'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
            
        }
    }
    

    app目录下的build.gradle文件作用:

    // 表示这是一个Android程序模块,如果是作为库,就声明为Library'com.android.library'
    apply plugin: 'com.android.application'
     
    android {
        compileSdkVersion 26 // 编译版本,指用哪个版本的SDK进行编译
        buildToolsVersion "26.0.1" //构建工具
        //对项目的更多细节进行配置
        defaultConfig {
            applicationId "com.seachal.myapplicationtestlog"
            minSdkVersion 19
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        //指定生成安装文件的相关配置
        buildTypes {
            //release 闭包用于指定生成正式版安装文件的配置
            release {
                minifyEnabled false //指定是否对项目的代码进行混淆, true 表示混淆, false 表示不混淆。
                //proguard-android.txt在默认的SDK目录下,有通用的混淆规则
                // proguard-rules.pro 有本项目专用的混淆规则
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
            //debug闭包可以忽略不写
        }
    }
    dependencies {
        //本地依赖声明,它表示将 libs 目录下所有.jar 后缀的文件都添加到项目的构建路径当中
        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:26.+'
        //com.android.support.constraint 是域名。constraint-layout是组名,用于区分同一公司的不同库。 1.0.2是版本号
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        //compile project(':helper')  //库依赖声明格式,表示依赖了一个叫helper的Library
        // 声明测试用例库
        testCompile 'junit:junit:4.12'
    }
    
  2. gradle-wrapper.properties文件的作用:指定gradle工具的路径。

    # distributionBase和distributionPath组合在一起,是解压gradle-5.4.1-all.zip之后的文件的存放位置。
    distributionBase=GRADLE_USER_HOME
    # distributionPath是distributionBase指定的目录下的子目录。
    distributionPath=wrapper/dists
    # zipStoreBase和zipStorePath组合在一起,是下载的gradle-5.4.1-all.zip所存放的位置。
    zipStoreBase=GRADLE_USER_HOME
    # zipStorePath是zipStoreBase指定的目录下的子目录。
    zipStorePath=wrapper/dists
    # distributionUrl是要下载的gradle的地址,使用哪个版本的gradle,就在这里修改。
    distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
    
    # 下载位置可以和解压位置不一样。
    # zipStoreBase和distributionBase有两种取值:GRADLE_USER_HOME和PROJECT。
    # 其中,GRADLE_USER_HOME表示用户目录。PROJECT表示项目目录。
    
  3. local.properties文件的作用:在Android Studio项目里面有个local.properties文件,这个文件可以放一些系统配置。比如:sdk路径、ndk路径。(里面的注释谷歌翻译结果)

    ## This file is automatically generated by Android Studio.
    ## 该文件由Android Studio自动生成。
    #
    # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
    # 请勿修改此文件-您的更改将被清除!
    #
    # This file should *NOT* be checked into Version Control Systems,
    # as it contains information specific to your local configuration.
    # 请勿*不要*将此文件签入版本控制系统,因为它包含特定于本地配置的信息。
    #
    # Location of the SDK. This is only used by Gradle.
    # SDK的位置。这仅由Gradle使用。
    #
    # For customization when using a Version Control System, please read the
    # header note.
    # 对于使用版本控制系统时的自定义,请阅读标题说明。
    sdk.dir=F\:\\Android\\sdk
    

    你也可以在local.properties中添加自定义的私有的配置,因为一般它不会被提交到服务器或者版本控制系统中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值