Android Dev

The right way to Migrate from Play Core Library

You will have lately acquired an electronic mail from Google Play Retailer stating the next:

Replace your Play Core Maven dependency to an Android 14 suitable model! Your present Play Core library is incompatible with targetSdkVersion 34 (Android 14), which introduces a backwards-incompatible change to broadcast receivers to enhance consumer safety. As a reminder, from August 31, Google Play requires all new app releases to focus on Android 14. Replace to the newest Play Core library model dependency to keep away from app crashes: https://developer.android.com/guide/playcore#playcore-migration

Chances are you’ll not be capable of launch future variations of your app with this SDK model to manufacturing or open testing.

Appears to be like horrifying, doesn’t it?

Don’t be so frightened. It’s truly simpler than it appears to be like.

What the Change is Truly About

Principally, Google stopped releasing new variations of the play core library again in early 2022.

Image
The final model of play core library launched

And from April 2022, they’ve damaged down the unique play core library into 4 separate libraries:

  • Play Property Supply Library
  • Play Characteristic Supply Library
  • Play In-App Evaluations Library
  • Play In-App Updates Library

Every library has its personal performance and duty.

For the reason that older core play library solely helps as much as a sure API degree, you’ll want to migrate your utility to make use of the newer libraries which have help for the latest API ranges.

In essence, you’ll want to determine which performance of the unique core play library you’re utilizing after which obtain the proper half. For instance, if you happen to had logic to inform customers when a more moderen model of your utility was out there, you’ll want to take the Play In-App-Updates library.

We shall be presenting two makes use of instances right here:

  • Native Android utility
  • Flutter utility

Use Case – Native Android App

When you have a local Android utility, whether or not it’s written in Kotlin or Java, you’ll want to do the next:

  1. Open your utility degree construct.gradle file
  2. Likely you will note below the dependencies block, this line:
implementation 'com.google.android.play:core-ktx:1.8.1'
  1. You will have to take away it and exchange it in response to what you used within the earlier core library

  2. If you’ll want to take the Play In-App-Updates library, then you’ll want to add these to the dependencies block:

implementation 'com.google.android.play:app-update:2.1.0'
//Add the dependency beneath in case you are utilizing Kotlin in your utility
implementation 'com.google.android.play:app-update-ktx:2.1.0'
  1. Rebuild your utility and see that every little thing works because it ought to.

✋ You may also want to vary import statements from import com.google.android.play.core.duties.*; to import com.google.android.gms.duties.*;.

Use Case – Flutter Utility

Since Flutter is a framework that caters to each Android and iOS, this state of affairs is a bit completely different from the one above. When you obtain the warning to improve the core play library in your Flutter utility, you want to take a look on the libraries you’re utilizing in your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  ...
  in_app_update: ^3.0.0

As you’ll be able to see above, the applying depends upon the in_app_update library, which has to do with notifying customers when a more moderen model of the applying is accessible. Once we head over to in_app_update’s pub.dev changelog page, we are able to see that:

Image
model 4.1.0 added the required help

So we have to replace our pubspec.yaml file to make use of that model (on the very least).

dependencies:
  flutter:
    sdk: flutter
  ...
  in_app_update: ^4.1.0

Run Pub get and try to be good to go.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker