当前位置: 首页 > news >正文

Android 中支持旧版 API 的方法(API 30)

Android 中最新依赖库的版本支持 API 31 及以上版本,若要支持 API30,则对应的依赖库的版本就需要使用旧版本。
可通过修改模块级 build.gradle 文件来进行适配。

1、android 标签的 targetSdk 和 compileSdk 版本号

根据实际目标设备的 android 版本来确定版本号,这里设备是 Android 11 版本的,故将targetSdk 和 compileSdk 设置为 30。

android {namespace 'com.example.helloworld'compileSdk 30defaultConfig {applicationId "com.example.helloworld"minSdk 23targetSdk 30versionCode 1versionName "1.0"testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"}
}

2、dependencies 标签中修改依赖库版本

dependencies {implementation 'androidx.core:core-ktx:1.6.0'implementation 'androidx.appcompat:appcompat:1.3.0'implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.1.3'implementation 'androidx.annotation:annotation:1.3.0'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'// 协程 lifecycleScopeimplementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
}

3、查询依赖库旧版本号

可在官网上查询某个依赖库的旧版本号信息。
网站:https://developer.android.google.cn/jetpack/androidx/explorer

在这里插入图片描述


http://www.mrgr.cn/news/97874.html

相关文章:

  • VS Code 的 .S 汇编文件里面的注释不显示绿色
  • 【网络安全 | 项目开发】Web 安全响应头扫描器(提升网站安全性)
  • LangChain4j(1):初步认识Java 集成 LLM 的技术架构
  • Spring Boot 自动加载流程详解
  • vLLM高效部署Qwen2.5-VL系列视觉大模型:从推理优化到Dify社区版集成
  • linux命令五
  • 【设备连接涂鸦阿里云】
  • 微服务简述
  • libva之ffavdemo分析
  • 【强内核论】 (1):向内求, 强内核 | 内核稳定的核心三要素 | 强内核的外在表现 | 老陈头 | 数字游牧社
  • Spring Cloud 通用相关组件详解
  • minio提供nfs服务
  • C/C++共有的类型转换与c++特有的四种强制类型转换
  • 【Pandas】pandas DataFrame head
  • 探索原生JS的力量:自定义实现类似于React的useState功能
  • pig 权限管理开源项目学习
  • C++项目:高并发内存池_下
  • C++初阶-C++的讲解1
  • 【NLP 面经 9、逐层分解Transformer】
  • vue 入门:组件事件