In a nutshell, Jetpack is Google’s official suite of
libraries, tools, and guidance to enable developers to write
high-quality apps more easily. Please read
here for more
details.
Why you should migrate to Jetpack?
The Jetpack libraries are a rebranding of the existing Android
libraries. Google took this opportunity to do some much needed
clean up of their Android libraries.
Migrating to Jetpack brings the following benefits:
Simplify app architecture by using Jetpack components.
Make it quick and easy to build robust, high-quality apps.
To be able to continue to use Google libraries and new Google
updates,
meaning that it will become a hard requirement if you
want to continue to use the latest Google libraries.
If you want to target the latest Android version, then you have
to migrate to Jetpack. Without that, you will be able to target
your application only to the Android API level 28 (Android 9).
Right now all of the Android Support Libraries have already
migrated to Jetpack. Additionally, all new libraries supported by
Google will be released as part of Jetpack.
Google libraries that are part of Jetpack
Room - modern Android database
Livedata - asynchronous UI updates
ViewModel - for MVVM architecture
All libraries that previously were developed under Support
Library project, for example AppCompat, CardView, ConstraintLayout,
Multidex
Starting with version
2.48.0
, our SDK
will be built with Jetpack. To make sure that your application will
handle this correctly, you should consider migrating your
application to Jetpack.
NOTE: You don’t have to migrate your project, if:
You are already using Jetpack.
You don’t use our PayButton integration.
How to verify if you need to migrate?
Open the
build.gradle
file and check if
you have any
com.android.support.*
dependencies and the
io.payworks:mpos.android.ui
dependency (PayButton). If
you do have both of these dependencies then you DO need to
migrate.
NOTE: Even if you don’t have to migrate your project yet,
it is very highly recommended to do so. Without migrating to
AndroidX you will not receive the latest updates from Google
libraries (like AppCompat).
Update your project to use Support Library version
28.0.0
Run automatic migration built-in Android Studio, click
Refactor -> Migrate to AndroidX
option.
Please use the latest Android Studio version available at the
moment.
Check if any other third-party libraries you may be using need
additional migration steps.
Make sure you are able to compile and run your project.
Update PayButton and other Payworks dependencies to version:
2.48.0
Right now you are ready to update your application to target
the latest Android version - you can set
targetSdkVersion 29
in your
build.gradle
.
Verify if migration is successful
After a successful migration you should find the following
changes in your project:
In the
gradle.properties
file you
should see the following lines:
android.useAndroidX=true
android.enableJetifier=true
In the
build.gradle
file you should see
that all
com.android.support.*
dependencies
are changed to
androidx.*
dependencies. For
example:
com.android.support:appcompat-v7:28.0.0
should be
changed to:
androidx.appcompat:appcompat:1.0.0
All imports in your classes and xml layouts are changed to use
the
androidx.*
namespace.
import
android.support.v7.app.AppCompatActivity
should be replaced
by:
import
androidx.appcompat.app.AppCompatActivity
android.support.constraint.ConstraintLayout
should be
replaced by:
androidx.constraintlayout.widget.ConstraintLayout
Video
describing the migration
List of Google libraries is found
here, it may help you
choose the proper libraries and versions.