强烈推荐gradle统一版本管理新方式version catalogs

https://developer.android.google.cn/build/migrate-to-catalogs?hl=zh-cn#groovy

以前都是通过自定义config.gradle, 然后apply它,有一个弊端就是无法提示新版本可以升级。比如这个:
请添加图片描述

在gradle7.0 preview了新功能,现在默认稳定了。
尝试一下,超级方便迁移,巨推荐!
几个好处:
以前自定义,无法提示新版本;而且无法点击跳转过去;
官方出品的,可以直接点击跳转,也可以在libs.versions.toml里面有提示。巨方便!

新建libs.versions.toml

在gradle目录下新建一个文件,libs.versions.toml

第二步根据ide提示操作

请添加图片描述
请添加图片描述
不论是新库还是旧库,都能提示你,可以选择换成已经存在的新版本或者老版本。

这里就花点时间,全部替换一下。
比如我这里libs.versions.toml,最终成型:

[versions]appcompat = "1.6.1"
constraintlayout = "2.1.4"
coreKtx = "1.13.1"
coreSplashscreen = "1.0.1"
datastorePreferences = "1.1.1"
espressoCore = "3.5.1"
glide = "4.16.0"
gson = "2.10.1"
junit = "4.13.2"
junitVersion = "1.1.5"
lifecycleLivedataKtx = "2.7.0"
material = "1.12.0"
mmkvStatic = "1.2.16"
navigationFragmentKtx = "2.7.7"
okhttpBom = "4.11.0"
recyclerview = "1.3.2"
roomRuntime = "2.6.1"
startupRuntime = "1.1.1"
swiperefreshlayout = "1.1.0"[libraries]androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" }
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCore" }
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "junitVersion" }
androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtx" }
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleLivedataKtx" }
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleLivedataKtx" }
androidx-lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "lifecycleLivedataKtx" }
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationFragmentKtx" }
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" }
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "roomRuntime" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomRuntime" }
androidx-startup-runtime = { module = "androidx.startup:startup-runtime", version.ref = "startupRuntime" }
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" }
glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
junit = { module = "junit:junit", version.ref = "junit" }
ksp = { module = "com.github.bumptech.glide:ksp", version.ref = "glide" }
material = { module = "com.google.android.material:material", version.ref = "material" }
mmkv-static = { module = "com.tencent:mmkv-static", version.ref = "mmkvStatic" }
okhttp = { module = "com.squareup.okhttp3:okhttp" }
okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttpBom" }
okhttp3-integration = { module = "com.github.bumptech.glide:okhttp3-integration", version.ref = "glide" }[plugins]

其他通用定制

Properties properties = new Properties()
InputStream inputStream = file('./local.properties').newDataInputStream()
properties.load(inputStream)
//全局的地方都可以使用这个来当做。
gradle.ext.selfUserName = properties.getProperty('username')
gradle.ext.selfPassword = properties.getProperty('password')
gradle.ext.jvmTarget           = "17"
gradle.ext.sourceCompatibility = JavaVersion.VERSION_17
gradle.ext.targetCompatibility = JavaVersion.VERSION_17
gradle.ext.compileSdk          = 34
gradle.ext.targetSdk           = 34
gradle.ext.minSdk              = 26

在settings.gradle里面添加如下代码。
然后给一些出现的地方定制进去

    compileOptions {sourceCompatibility gradle.ext.sourceCompatibilitytargetCompatibility gradle.ext.targetCompatibility}kotlinOptions {jvmTarget = gradle.ext.jvmTarget}

官方出品,简单快捷,有提示,能跳转。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/669495.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

论文笔记:DeepMove: Predicting Human Mobility with Attentional Recurrent Networks

WWW 2018 1 Intro 根据对百万级用户群的研究,93%的人类移动是可预测的。 早期的mobility预测方法大多基于模式的。 首先从轨迹中发现预定义的移动模式(顺序模式、周期模式)然后基于这些提取的模式预测未来位置。最近的发展转向基于模型的方法进行流动性预测。 利用…

C语言结构体类型

C语言结构体类型 个人主页:大白的编程日记 个人主页:C语言学习之路 文章目录 C语言结构体类型前言一.结构体1.1结构体类型的声明1.2结构体变量的创建和初始化1.3结构成员访问操作符1.4结构的特殊声明1.5 结构的自引用 二.结构体内存对齐2.1对齐规则2.2内…

UDP 的报文结构

一.UDP的报文结构 1.UDP的简单介绍 UDP是传输层协议,它是无连接,不可靠传输,面向数据报,全双工 1.无连接:UDP是一种无连接的传输协议,通信双方不需要在发送数据之前建立连接。相比之下,TCP是面向连接的协议,在传输数…

基于大模型(LLM)相互协商的情感分析

Sentiment Analysis through LLM Negotiations https://arxiv.org/abs/2311.01876https://arxiv.org/abs/2311.01876 1.概述 在情感分析任务中,传统的单一大型语言模型(LLM)通常只通过单轮输出来做出决策。这种方法的主要缺点是无法完美应对需要深入推理的复杂语言现象,…

[Java、Android面试]_22_APP启动流程(中频问答)

欢迎查看合集: Java、Android面试高频系列文章合集 本人今年参加了很多面试,也有幸拿到了一些大厂的offer,整理了众多面试资料,后续还会分享众多面试资料。 整理成了面试系列,由于时间有限,每天整理一点&am…

【LinuxC语言】信号的基本概念与基本使用

文章目录 前言一、信号的概念二、信号的使用2.1 基本的信号类型2.2 signal函数 总结 前言 在Linux环境下,信号是一种用于通知进程发生了某种事件的机制。这些事件可能是由操作系统、其他进程或进程本身触发的。对于C语言编程者来说,理解信号的基本概念和…

利用github pages建立Serverless个人博客

利用github pages建立Serverless个人博客 概述 使用github pages,可以在github上部署静态网站。利用这个功能,可以很方便地实现个人博客的发布托管。 比如我的个人博客:Buttering’s Blog 对应代码仓库:buttering/EasyBlog: 自…

什么是流星烛台?昂首资本一分钟讲解

各位投资者:五一劳动节快乐! 什么是流星烛台图?都有什么特征?今天Anzo Capital昂首资本一分钟给各位投资者讲解清楚! 流星烛台图其实很好理解,就是类似流星的烛台图。流星烛台图看起来与流星相同&#x…

JetPack之ViewModel+LiveData

目录 一、概述二、LiveData 使用2.1 创建 LiveData 对象2.2 观察 LiveData 对象2.3 更新 LiveData 对象 三、编写 LiveData Demo3.1 不使用 LiveData3.2 使用 MutableLiveData3.3 使用 MediatorLiveData3.3.1 监听 2 个数据源的变化3.3.2 编写模拟 2 个数据源更新的代码 四、Vi…

张大哥笔记:引流108招,让天下没有难搞的流量

时至今日,流量有多重要不用我多说。 不管网络还是实体所有项目都需要引流。 赚钱的公式很简单: 流量产品赚钱。 产品可以是实物,也可以是服务,更可以是虚拟商品。 甚至有些时候,没有产品,只有流量,你也…

03.配置监控一台服务器主机

配置监控一台服务器主机 安装zabbix-agent rpm -ivh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.11-1.el7.x86_64.rpm配置zabbix-agent,配置的IP地址是zabbix-server的地址,因为要监控这台主机 vim /etc/zabbix/zab…

今日分享【CSS中的经典使用】

经典双飞翼布局 先看效果 双飞翼布局要求: 1、header和footer各自占领屏幕所有宽度,高度固定。 2、中间的container是一个三栏布局。 3、三栏布局两侧宽度固定不变,中间部分自动填充整个区域。 4、中间部分的高度是三栏中最高的区域的高度。…