在遇到问题中提到的几个问题后,我成功地将我的项目的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 - 在项目 gradle 中添加 google() 存储库
repositories {
jcenter()
google()
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com'
}
google()
}
}
7 - 在 app gradle 中添加 Java 8 为 compileOption
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 - 小部件属性弃用
如上所述,一些小部件可能与之前完成的更新有关,因此请务必检查您的布局是否有弃用或问题
注意:
如果这里有什么需要注意或添加的,那就太好了。希望它会在未来对其他人有所帮助。