Android Jetpack Migration Guide
What is Android Jetpack?
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).
How to migrate?
- Update your project to use Support Library version28.0.0
- Run automatic migration built-in Android Studio, clickRefactor -> Migrate to AndroidXoption. 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 settargetSdkVersion 29in yourbuild.gradle.
If you face any problems during the migration process, please
refer to official
migration guide provided by Google.
Verify if migration is successful
After a successful migration you should find the following
changes in your project:
- In thegradle.propertiesfile you should see the following lines:android.useAndroidX=trueandroid.enableJetifier=true
- In thebuild.gradlefile you should see that allcom.android.support.*dependencies are changed toandroidx.*dependencies. For example:com.android.support:appcompat-v7:28.0.0should be changed to:androidx.appcompat:appcompat:1.0.0
- All imports in your classes and xml layouts are changed to use theandroidx.*namespace.For example:import android.support.v7.app.AppCompatActivityshould be replaced by:import androidx.appcompat.app.AppCompatActivityIn xml layouts:android.support.constraint.ConstraintLayoutshould be replaced by:androidx.constraintlayout.widget.ConstraintLayout
Additional resources