Introduction to 2 types of build.gradle files in Android Studio

Source: Internet
Author: User

Build.gradle in the root directory usually does not need to modify the contents of this file unless you need to add some global project build configuration

Buildscript {        repositories {        Google ()    //claim Code hosting warehouse Google        Jcenter ()   //Claim code hosting warehouse, For referencing open source projects on Jcenter    }    dependencies {        classpath ' com.android.tools.build:gradle:3.1.0 '        // A Gradle plugin was declared to be used as an Android developer. 3.1.0 for Gradle version number    }}allprojects {    repositories {        Google ()    //Claim Code hosting warehouse        jcenter ()    }}task Clean (type:delete) {    Delete Rootproject.builddir}

The Build.gradle file in the app directory is the Gradle build script for the app module, typically used to manage app package names, versions, and add and modify dependent libraries.

Apply plugin: ' com.android.application '//Application module Android {compilesdkversion 26//Specify to use the compiled version of the project Defaultconfig { ApplicationID "Com.example.helloworld"//Package name Minsdkversion 15//Specify the minimum compatible Android version of the project Targetsdkver        Sion 26//indicates that the ANDROID26 version has been fully tested Versioncode 1//Project version number Versionname "1.0"//Version Name            Testinstrumentationrunner "Android.support.test.runner.AndroidJUnitRunner"} buildtypes {release { Minifyenabled false//whether to code obfuscation proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' proguard-rules. Pro '//Specify obfuscation rule file}}}dependencies {//* Specifies all dependencies for the current project implementation Filetree (dir: ' Libs ', include: [ ' *.jar ')//local dependency declaration: Adds a local jar package, directory add dependency, add to the project's build path implementation ' com.android.support:appcompat-v7:26.1.0 ' Implem Entation ' com.android.support.constraint:constraint-layout:1.0.2 '//Remote dependency declaration testimplementation ' junit:junit:4.12 '/ /used to declare the test case library}

  

Introduction to 2 types of build.gradle files in Android Studio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.