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