包阅导读总结
1.
关键词:Play Core Library、Migration、Android 14、Library Versions、Flutter Application
2.
总结:本文主要讲述因 Android 14 引入变更,需将 Play Core Maven 依赖更新为兼容版本。介绍了 Play Core 库的变化及拆分情况,针对原生安卓应用和 Flutter 应用给出迁移案例,包括依赖修改和版本更新等操作。
3.
主要内容:
– 背景
– 收到 Google Play Store 邮件,要求更新 Play Core Maven 依赖到 Android 14 兼容版本。
– 变化
– 2022 年初 Google 停止发布新的 Play Core 库版本,并于 2022 年 4 月拆分为四个库。
– 用例
– 原生安卓应用
– 打开应用级 build.gradle 文件,根据使用情况移除和替换依赖。
– 可能需更改导入语句。
– Flutter 应用
– 在 pubspec.yaml 文件中更新相关库的版本。
– 运行 Pub get。
思维导图:
文章地址:https://www.freecodecamp.org/news/migrate-from-play-core-library/
文章来源:freecodecamp.org
作者:Tomer
发布时间:2024/6/26 17:53
语言:英文
总字数:555字
预计阅读时间:3分钟
评分:90分
标签:Android,Android应用程序开发
以下为原文内容
本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com
You may have recently received an email from Google Play Store stating the following:
Update your Play Core Maven dependency to an Android 14 compatible version! Your current Play Core library is incompatible with targetSdkVersion 34 (Android 14), which introduces a backwards-incompatible change to broadcast receivers to improve user security. As a reminder, from August 31, Google Play requires all new app releases to target Android 14. Update to the latest Play Core library version dependency to avoid app crashes: https://developer.android.com/guide/playcore#playcore-migration
You may not be able to release future versions of your app with this SDK version to production or open testing.
Looks frightening, doesn’t it?
Don’t be so worried. It is actually easier than it looks.
What the Change is Actually About
Basically, Google stopped releasing new versions of the play core library back in early 2022.
The last version of play core library released
And from April 2022, they have broken down the original play core library into four separate libraries:
- Play Assets Delivery Library
- Play Feature Delivery Library
- Play In-App Reviews Library
- Play In-App Updates Library
Each library has its own functionality and responsibility.
Since the older core play library only supports up to a certain API level, you need to migrate your application to use the newer libraries that have support for the most recent API levels.
In essence, you need to figure out which functionality of the original core play library you are using and then download the correct part. For example, if you had logic to notify users when a newer version of your application was available, you need to take the Play In-App-Updates library.
We will be presenting two uses cases here:
- Native Android application
- Flutter application
Use Case – Native Android App
If you have a native Android application, whether it is written in Kotlin or Java, you need to do the following:
- Open your application level build.gradle file
- Most probably you will see under the dependencies block, this line:
implementation 'com.google.android.play:core-ktx:1.8.1'
-
You will need to remove it and replace it according to what you used in the previous core library
-
If you need to take the Play In-App-Updates library, then you need to add these to the dependencies block:
implementation 'com.google.android.play:app-update:2.1.0'//Add the dependency below if you are using Kotlin in your applicationimplementation 'com.google.android.play:app-update-ktx:2.1.0'
- Rebuild your application and see that everything works as it should.
✋ You might also need to change import statements from import com.google.android.play.core.tasks.*; to import com.google.android.gms.tasks.*;.
Use Case – Flutter Application
Since Flutter is a framework that caters to both Android and iOS, this scenario is a bit different from the one above. If you receive the warning to upgrade the core play library in your Flutter application, you need to have a look at the libraries you are using in your pubspec.yaml file:
dependencies: flutter: sdk: flutter ... in_app_update: ^3.0.0
As you can see above, the application depends on the in_app_update library, which has to do with notifying users when a newer version of the application is available. When we head over to in_app_update’s pub.dev changelog page, we can see that:
version 4.1.0 added the required support
So we need to update our pubspec.yaml file to use that version (at the very least).
dependencies: flutter: sdk: flutter ... in_app_update: ^4.1.0
Run Pub get and you should be good to go.