gpt4 book ai didi

android - 针对 API 28 更新

转载 作者:行者123 更新时间:2023-11-30 04:58:57 24 4
gpt4 key购买 nike

我有几个目标为 SDK 26 的应用程序,众所周知,自从谷歌为 play store SDK 要求应用新规则以来,我必须更新我的目标 SDK 到 28 其中涉及大量更新!

我最近几天尝试进行更新,但遇到了很多错误:

  • 支持库冲突
  • 梯度冲突
  • 第三库冲突

所以我将所有内容都设置回目标 API 26 以在更新明确目标 API 28 之前对应用程序进行一些更改。

我的问题:最好的方法/预期是什么,我必须使用什么最好的 android studio 版本来避免此类冲突。

最佳答案

在遇到问题中提到的几个问题后,我成功地将项目的 targetSdkVersioncompileSdkVersion 更新为 28 ,在这里我将写下我遵循的所有步骤和所做的更改。

  • 我 - 步骤:

1 - 将我的 android studio 更新到最新版本

2 - 更新我的 gradle 插件版本,gradle 版本 (5.4.1)

dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
.........
}

3 - 迁移到 androidx

4 - 将所有第 3 个库(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 - 在应用程序 gradle 中将 Java 8 添加为 compileOption

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
  • II - 变化:

对于更改,它实际上取决于您使用的小部件和库,但通常应该提及一些要点:

<强>1。启用对所有类型连接的请求 HTTP 和 HTTPS

usesCleartextTraffic 添加到 AndroidManifest.xml

<application
...
android:usesCleartextTraffic="true"
...>

指示应用是否打算使用明文网络流量,例如明文 HTTP。针对 API 级别 27 或更低级别的应用的默认值为 “true”。以 API 级别 28 或更高级别为目标的应用默认为 “false”

2 - 弃用和方法变更

某些方法会被提及为已弃用甚至未找到,因此请确保检查代码的每一行以更新或重写可疑方法

3 - 小部件属性弃用

如上所述,一些小部件可能与之前完成的更新有关,因此请务必检查您的布局是否已弃用或出现问题


注意:

如果这里有什么需要注意或补充的,那就太好了。希望它能在将来帮助其他人。

关于android - 针对 API 28 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58573484/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com