DEV Community

Devstories Playground
Devstories Playground

Posted on

Android Migration

Hey devs.

I like to migrate my old repositories to the latest android version. Any ideas or article that can make it easier? I'm planning to continue my old projects.

Top comments (2)

Collapse
 
subbramanil profile image
Subbu Lakshmanan • Edited

Hi Mina,

The difficulty of migration depends on how older the projects are. The latest version of Android Studio ships with Upgrade Assistant which automatically helps with upgrading an older android project. It does that by detecting the gradle version of the project and asks for confirmation to upgrade. While this is not guaranteed to be 100% successful, it can be a good start.

In addition, I'd recommend taking this approach.

Assumption: You have installed the latest stable version of android studio & JDK.

Preparation Step:

Create a brand new project in the Android Studio with a simple screen & Run the app. Since Android Studio auto-generates the project files, it will have the latest/stable Gradle, Gradle-wrapper versions, and the android libraries version. Note these values from the build.gradle file.

  • From build.gradle
classpath "com.android.tools.build:gradle:X.X.X"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:Y.Y.Y"
Enter fullscreen mode Exit fullscreen mode
  • From gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-X.X.X-bin.zip
Enter fullscreen mode Exit fullscreen mode

Now open the old project,

  1. The first step is to ensure the app can sync (i.e., the android SDK, Support libraries & 3rd party libraries are downloaded). The gradle sync/build will most likely fail if the gradle version is older. I'd replace the gradle version & gradle-wrapper versions and sync.
    Note:: jcenter() is no longer available, use google() & mavenCentral() for repositories

  2. The second step is to check if the app can be built with the existing code & library versions. The success of this step depends on the current code (assumption: free of compilation error) & availability of Android Support & 3rd party libraries.

  3. The last step is to update the necessary libraries & bringing the app up to date. Android Studio would show warnings on obsolete versions and help update the libraries. Android Studio also supports updating Kotlin migration from older to the latest versions.

Collapse
 
devstoriesplayground profile image
Devstories Playground

Thank you!!! I will definitely try this. 🙂