1.关于settings.gradle的变化
原来的
include ':app'
include ':marqueeview'
7.0+以后
pluginManagement {
repositories {
gradlePluginPortal()
//华为maven
maven {
url "http://developer.huawei.com/repo/"
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/google'
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin'
allowInsecureProtocol = true
}
google()
mavenCentral()
//noinspection JcenterRepositoryObsolete
jcenter()
maven { url 'https://jitpack.io' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
//华为maven
maven {
url "http://developer.huawei.com/repo/"
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/google'
allowInsecureProtocol = true
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin'
allowInsecureProtocol = true
}
maven { url "https://jitpack.io" }
google()
mavenCentral()
jcenter()
}
}
rootProject.name = "MvvmKotlinProject"
include ':LocalPackage:AutoSize_aar'
include ':LocalPackage:Banner_aar'
include ':LocalPackage:LoadSir_aar'
include ':LocalPackage:CircleImageView_aar'
include ':LocalPackage:ImmersionBar_aar'
include ':LocalPackage:ImmersionBar_Components_aar'
include ':LocalPackage:ImmersionBar_Ktx_aar'
include ':LocalPackage:SuperTextView_aar'
enableFeaturePreview('VERSION_CATALOGS')
dependencyResolutionManagement {
versionCatalogs {
libs {
from(files("libs.versions.toml"))
}
}
}
include ':app'
include ':marqueeview'
2.关于项目的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
classpath "com.alibaba:arouter-register:1.0.2"
}
}
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
id 'org.jetbrains.kotlin.jvm' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
3.app或者module内的build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'version-catalog'
id 'com.jakewharton.butterknife'
}
android {
namespace 'it.dongjun.yigui'
compileSdk libs.versions.compilesdk.get().toInteger()
defaultConfig {
applicationId "it.dongjun.yigui"
minSdk libs.versions.minsdk.get().toInteger()
targetSdk libs.versions.targetsdk.get().toInteger()
versionCode libs.versions.versioncode.get().toInteger()
versionName libs.versions.versionname.get().toString()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
task makeJar(type: Copy) {
delete 'build/outputs/baselibrary.jar'
from('build/intermediates/compile_library_classes_jar/release') //jar文件来源
into('build/outputs/') //生成路径
include('classes.jar')
rename('classes.jar', 'baselibrary.jar')//mylibrary.jar 生成jar包的名称
}
makeJar.dependsOn(build)
}
catalog {
versionCatalog {
from files('../libs.versions.toml')
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
4.加上版本统一管理libs.versions.toml的使用和配置
# [versions] 部分用于声明可以被依赖项引用的版本
# [libraries] 部分用于声明 Library 的别名
# [bundles] 部分用于声明依赖包
# [plugins] 部分用于声明插件
[versions]
# android defaultConfig
minsdk = "21"
targetsdk = "32"
compilesdk = "32"
versioncode = "101"
versionname = "1.0.2"
# SDK
kotlin = "1.6.10"
lifecycle = "2.4.0"
retrofit = "2.9.0"
glide = "4.13.2"
room = "2.4.2"
picker = "4.1.9"
[libraries]
# androidX
core-ktx = "androidx.core:core-ktx:1.7.0"
appcompat = "androidx.appcompat:appcompat:1.3.1"
material = "com.google.android.material:material:1.4.0"
fragment = "androidx.fragment:fragment-ktx:1.4.0"
constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.1"
recyclerview = "androidx.recyclerview:recyclerview:1.2.1"
cardview = "androidx.cardview:cardview:1.0.0"
# lifecycle 生命周期管理
lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
lifecycle-livedata = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" }
lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
# BaseRecyclerView
baserecyclerview = "com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.7"
# 腾讯 mmkv
mmkv = "com.tencent:mmkv:1.2.12"
utilcodex = "com.blankj:utilcodex:1.30.6"
# popup 弹窗
basepopup = "io.github.razerdp:BasePopup:3.2.0"
# permissionx
permissionx = "com.guolindev.permissionx:permissionx:1.6.4"
# 连点 防抖动
rxbinding = "com.jakewharton.rxbinding4:rxbinding:4.0.0"
# material-dialogs
commons-dialogs = "com.afollestad.material-dialogs:commons:0.9.6.0"
# splashscreen
splashscreen = "androidx.core:core-splashscreen:1.0.0-alpha02"
# PersistentCookieJar
persistent-cookie-jar = "com.github.franmontiel:PersistentCookieJar:v1.0.1"
# AgentWeb
agentWeb = "com.github.Justson.AgentWeb:agentweb-core:v5.0.0-alpha.1-androidx"
# okhttp 日志拦截器
logging-interceptor = "com.squareup.okhttp3:logging-interceptor:4.9.2"
# RxAndroid
rxandroid = "io.reactivex.rxjava3:rxandroid:3.0.0"
# multidex
multidex = "com.android.support:multidex:1.0.2"
# xcrash
xcrash = "com.iqiyi.xcrash:xcrash-android-lib:3.0.0"
#api 'me.yokeyword:fragmentationx:1.0.2'
#api 'com.kaopiz:kprogresshud:1.0.2'
# retrofit RxJava3 + retrofit2 + RxBinding。注意,RxBinding内包含RxJava2,所以不要再次引入RxJava2依赖
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
converter-scalars = { module = "com.squareup.retrofit2:converter-scalars", version.ref = "retrofit" }
adapter-rxjava3 = { module = "com.squareup.retrofit2:adapter-rxjava3", version.ref = "retrofit" }
# Glide 图片加载、缓存、转换
glide-core = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
glide-compiler = { module = "com.github.bumptech.glide:compiler", version.ref = "glide" }
#glide-transformations = "jp.wasabeef:glide-transformations:4.3.0"
# Room 数据库
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
room-rxjava2 = { module = "androidx.room:room-rxjava2", version.ref = "room" }
room-rxjava3 = { module = "androidx.room:room-rxjava3", version.ref = "room" }
room-guava = { module = "androidx.room:room-guava", version.ref = "room" }
room-testing = { module = "androidx.room:room-testing", version.ref = "room" }
room-paging = "androidx.room:room-paging:2.5.0-alpha01" #Paging 3 Integration
roomkapt = { module = "androidx.room:room-compiler", version.ref = "room" }
#// To use Kotlin Symbolic Processing (KSP)
#ksp("androidx.room:room-compiler:$roomVersion")
#//界面管理
#'fragmentationx' : "me.yokeyword:fragmentationx:1.0.2",
#'swipeback' : "me.yokeyword:fragmentation-swipeback:1.3.7",
#androidPicker选择器类库
#androidpicker = "com.github.gzu-liyujiang.AndroidPicker:Common:4.1.9"
picker-common = { module = "com.github.gzu-liyujiang.AndroidPicker:Common", version.ref = "picker" }
picker-wheelview = { module = "com.github.gzu-liyujiang.AndroidPicker:WheelView", version.ref = "picker" }
picker-wheelPicker = { module = "com.github.gzu-liyujiang.AndroidPicker:WheelPicker", version.ref = "picker" }
picker-AddressPicker = { module = "com.github.gzu-liyujiang.AndroidPicker:AddressPicker", version.ref = "picker" }
picker-FilePicker = { module = "com.github.gzu-liyujiang.AndroidPicker:FilePicker", version.ref = "picker" }
picker-ColorPicker = { module = "com.github.gzu-liyujiang.AndroidPicker:ColorPicker", version.ref = "picker" }
picker-CalendarPicker = { module = "com.github.gzu-liyujiang.AndroidPicker:CalendarPicker", version.ref = "picker" }
picker-ImagePicker = { module = "com.github.gzu-liyujiang.AndroidPicker:ImagePicker", version.ref = "picker" }
[bundles]
glide = ["glide-core", "glide-compiler"]#, "glide-transformations"]
androidx = ["core-ktx", "appcompat", "material", "fragment", "constraintlayout", "recyclerview", "cardview"]
lifecycle = ["lifecycle-runtime", "lifecycle-livedata", "lifecycle-viewmodel"]
retrofit = ["retrofit", "converter-gson", "converter-scalars", "adapter-rxjava3"]
room = ["room-runtime", "room-compiler", "room-ktx", "room-rxjava2", "room-rxjava3", "room-guava", "room-testing"]
picker = ["picker-common", "picker-wheelview", "picker-wheelPicker"]