If you want your application to be compatible with latest Android Version Q with API level 29, We will have to change app/build.gradle with compileSdkVersion & targetSdkVersion changed to to 29.
But since android uses androidx after API 29, if our application was using libraries from API 28, we may see the problem like below during compilation,
Error: Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with this: Refactor > Migrate to AndroidX... [GradleCompatible]
The Solution to this problem is as mentioned in error message, we have to upgrade our application to AndroidX libraries, this can be done as,
Open your application in Android Studio and from “Refactor” option in Studio, click on “Migrate to Android X” once you click there in bottom left you will see “Do Refactor” button enabled, click on the same and Android Studio will automatically modify necessary files to migrate to start using AndroidX libraries.
For more information, refer to “Migrating your apps to Android 10“