Preparing the migration

As we said, we need to make a decision whether we will completely rewrite our modules into Kotlin or continue writing our code in Kotlin but keep its legacy in pure Java. What will we do? In this chapter, we will demonstrate a little bit of each.

Our current project, at this point, doesn't have anything to migrate. So, we will create some code. If you don't have the Java sources directory with the packages structure, create it. Now, add the following packages:

  • activity
  • model

These packages are equivalent to the packages we already have in our Kotlin source code. In the activity package, add the following classes:

  • The MigrationActivity.java code is as follows:
 package com.journaler.activity; import android.os.Bundle; ...

Get Mastering Android Development with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.