Skip to content
Advertisement

Convert an existing Flutter Kotlin project to Flutter Java project

I created a Flutter project using default values, which are Kotlin for Android and Swift for iOS. Halfway through the project I needed to integrate a 3rd party Android SDK that requires Java. Can I convert a Flutter project to Java for Android after creation?

I know I will need yo use Platform Channels to integrate native code with my Flutter app, this is not my concern.

Advertisement

Answer

I had the same problem, for me this solution works.

  1. Move folder com.example.test_app (any name you have) from android/app/src/main/kotlin -> android/app/src/main/java
  2. Replace MainActivity.kt with Java version, or copy down here

    JavaScript
  3. Remove following code android/app/build.grandle

    JavaScript
  4. In the same place replace following:

    JavaScript

    to

    JavaScript
Advertisement