zoukankan      html  css  js  c++  java
  • Android studio中2种build.gradle文件介绍

    根目录下的build.gradle通常不需要修改这个文件中的内容,除非需要添加一些全局的项目构建配置

    buildscript {
        
        repositories {
            google()    //声明代码托管仓库Google
            jcenter()   //声明代码托管仓库,用于引用jcenter上的开源项目
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.0'
            //声明了一个Gradle插件用来作为Android开发。3.1.0为gradle版本号
    
        }
    }
    allprojects {
        repositories {
            google()    //声明代码托管仓库
            jcenter()
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    APP目录下的build.gradle文件是app模块的gradle构建脚本,一般用来管理app包名、版本的以及添加和修改依赖库。

    apply plugin: 'com.android.application' //应用 应用程序模块
    
    android {
        compileSdkVersion 26    //指定使用项目的编译版本
        defaultConfig {
            applicationId "com.example.helloworld"  //包名
            minSdkVersion 15        //指定项目最低兼容的Android版本
            targetSdkVersion 26     //表示Android26版本上已经进行过充分的测试
            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'])
        //本地依赖声明:将本地的jar包、目录添加依赖关系,添加到项目的构建路径当中
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        //远程依赖声明
        testImplementation 'junit:junit:4.12'   //用以声明测试用例库
    }
    

      

  • 相关阅读:
    1014 Waiting in Line (30)(30 point(s))
    1013 Battle Over Cities (25)(25 point(s))
    1012 The Best Rank (25)(25 point(s))
    1011 World Cup Betting (20)(20 point(s))
    1010 Radix (25)(25 point(s))
    1009 Product of Polynomials (25)(25 point(s))
    1008 Elevator (20)(20 point(s))
    1007 Maximum Subsequence Sum (25)(25 point(s))
    1006 Sign In and Sign Out (25)(25 point(s))
    1005 Spell It Right (20)(20 point(s))
  • 原文地址:https://www.cnblogs.com/liqiujiong/p/8734518.html
Copyright © 2011-2022 走看看