buildscript的repositories与allprojects中的repositories区别

有时需要使用第三方的库,需要在线依赖,比如我下面这端代码:


buildscript {

    repositories {
        maven { url'https://maven.aliyun.com/repository/public/' }
        maven { url'https://maven.aliyun.com/repository/google/' }
        maven { url'https://maven.aliyun.com/repository/jcenter/' }
        maven { url'https://maven.aliyun.com/repository/central/' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'//配置EventBu
        configurations {
            all*.exclude group: 'com.android.support:support-v4:28.0.0', module: 'support-v13'
        }
    }
}

allprojects {

    repositories {
        maven { url"https://raw.githubusercontent.com/HyphenateInc/Hyphenate-SDK-Android/master/repository" }
        maven { url'https://maven.aliyun.com/repository/public/' }
        maven { url'https://maven.aliyun.com/repository/google/' }
        maven { url'https://maven.aliyun.com/repository/jcenter/' }
        maven { url'https://maven.aliyun.com/repository/central/' }
        maven { url 'https://jitpack.io' }
        mavenCentral()

    }
}

 

有时候就傻傻分不清他们的关系,经常写错,现在做个笔记:

1、buildscript是gradle脚本执行需要的依赖,分别是对应的maven库和插件

2、allprojects里是项目本身需要的依赖, 比如我们平时用到的第三库用到了自己的maven库,就需要在这引入。

详细介绍可看官网资料:https://developer.android.com/studio/build

 

 

 



 

你可能感兴趣的:(Android)