android - 定位 API 28 更新
问题描述
我有几个带有 target 的应用程序,SDK 26
众所周知,自从 google 对 Play 商店SDK
要求应用了新规则后,我必须将我的 target 更新SDK
为 28,这涉及到很多更新!
我最近几天尝试进行更新,但遇到了很多错误:
- 支持库冲突
- 梯度冲突
- 第三图书馆冲突
因此,我将一切都设置回 targetAPI 26
以在应用程序上进行一些更改,然后再明确更新为 target API 28
。
我的问题是:为了避免此类冲突,我必须使用的最佳方法/预期和最佳 android studio 版本是什么。
解决方案
在遇到问题中提到的几个问题后,我成功地将我的项目更新为targetSdkVersion
, 在这里我将写下我遵循的所有步骤以及我所做的更改。compileSdkVersion
28
- 我 - 步骤:
1 - 将我的 android studio 更新到最新版本
2 - 更新我的 gradle 插件版本,gradle 版本(5.4.1)
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
.........
}
3 - 迁移到androidx
图书馆
4 - 将所有 3rd 库(Firebase、google play services、Picasso ......)更新到最新版本
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.f0ris.sweetalert:library:1.5.1'
implementation 'com.google.firebase:firebase-messaging:20.0.1'
..........
..........
5 -google-services
将插件版本更新到最新版本
dependencies {
........
classpath 'com.google.gms:google-services:4.3.3'
}
6 -google()
在项目 gradle 中添加存储库
repositories {
jcenter()
google()
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com'
}
google()
}
}
7 -compileOption
在 app gradle 中添加 Java 8
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
- 二 - 变化:
对于更改,它确实取决于您正在使用的小部件和库,但通常应该提到一些重要的点:
1. 启用对所有类型连接 HTTP 和 HTTPS 的请求
添加usesCleartextTraffic
到AndroidManifest.xml
<application
...
android:usesCleartextTraffic="true"
...>
指示应用程序是否打算使用明文网络流量,例如明文HTTP。API
面向级别27
或更低级别的应用的默认值为"true"
. 目标API
级别28
或更高级别的应用默认为"false"
.
2 - 弃用和方法更改
某些方法将被提及为已弃用甚至找不到,因此请确保检查代码的每一行以更新或重写可疑方法
3 - 小部件属性弃用
如上所述,一些小部件可能与之前完成的更新有关,因此请务必检查您的布局是否有弃用或问题
注意:
如果这里有什么需要注意或添加的,那就太好了。希望它会在未来对其他人有所帮助。
推荐阅读
- r - 将 NA 替换为子集组内的值
- api - 使用invokehttp将多个文件发布到使用nifi的API
- c# - Powershell - 在作业中调用 C# 函数
- c++ - 如何使用鼠标单击选择多个 QLabel 对象?
- python-3.x - 从整数值比较中获取布尔值列表
- sql - 使用sql计算同名下的分钟
- python - 机器人框架命令行错误 | 出现错误“utf8”编解码器无法解码位置 0 中的字节 0xd0:无效的继续字节
- php - 读取 XML 中的特定属性 - Laravel orchestra Parser
- python - Tensorflow js:错误:检查时出错:预期 conv2d_13_input 有 4 个维度,但得到了形状为 [100,120,3] 的数组
- javascript - 有没有办法使用一个处理程序同时编辑图像和输入字段?