根目录下 build.gradle 变更
变更前:
buildscript {
ext.kotlin_version = '1.5.0'
repository {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.17"
// 自定义 gradle 插件
classpath "com.sharpcj.plugin:abc:1.0.6"
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven {
url "http://xx.xx.xx.xx:xxxx/xx/xx/"
}
}
}
变更后:
根目录下的 buildscript 变更到 settings.gradle 中
setting.gradle
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven {
allowInsecureProtocol = true
url "http://xx.xx.xx.xx:xxxx/xx/xx/"
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
allowInsecureProtocol = true
url "http://xx.xx.xx.xx:xxxx/xx/xx/"
}
}
}
gradle 7.0.x 以上对于 http 协议的的仓库地址,需要显示声明:allowInsecureProtocol = true
根目录下 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// 全局 buildescript 依旧可以用
buildscript {
ext.kotlin_version = '1.5.0'
// 自定义 gradle 插件
dependencies {
classpath "com.sharpcj.plugin:abc:1.0.6"
}
}
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
id 'com.google.protobuf' version '0.8.17' apply false
}
引入 aar 包gradle
7.0.x 以前:
-
将aar文件复制到libs文件夹中
-
在 model 下 build.gradle 中的 android {} 外层添加:
repositories {
flatDir {
dirs 'libs'
}
}
- 在 dependencies 中加入
implementation files('libs/xxx.jar')
或者:
implementation(fileTree("libs"));
7.0.x 以上:
- 将aar文件复制到libs文件夹中
- build.gradle的dependencies中加入:
implementation(fileTree("libs"));
标签:gradle,xx,version,build,libs,一些,com,变更
From: https://www.cnblogs.com/joy99/p/17298745.html