Storage location of gradle dependencies

app Android project files in this build.gradle module as follows:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.administrator.myapplication"
        minSdkVersion 15
        targetSdkVersion 26
        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'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:multidex:1.0.3'

}

If the project outermost build.gradle file:

// 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:3.1.0'
        

        // 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
}

Closure of repositories written google () or jcenter () and the like, then, for the closure of the following dependencies declared all depend, gradle when building will go to download, cache in C: \ Users \ Administrator.gradle \ caches \ under modules-2 \ files-2.1 directory, such as:
Here Insert Picture Description

However, if the project outermost build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
       mavenLocal()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Closure of repositories written mavenLocal () (that is, the use of local warehouse), it will not go gradle download at build time, but to use mavenLocal () warehouse dependent packages build, mavenLocal () default path Warehouse They are: /home/user/.m2/repository (which is, windows system under Linux is similar).

Note here that if mavenLocal () in the package is dependent aar format, then gradle when it will be built into jar format and stores the converted dependencies in C: \ Users \ Administrator.gradle \ caches \ transforms-1 \ files-1.1 \ directory, such as C: \ Users \ Administrator.gradle \ caches \ transforms-1 \ files-1.1 \ multidex-1.0.3.aar:
Here Insert Picture Description

Published 486 original articles · won praise 88 · views 720 000 +

Guess you like

Origin blog.csdn.net/yzpbright/article/details/89001633