How to deal with flutter Java/Kotlin
486
Since the latest version of flutter the android project is created with kotlin by default. You can change this deleting the android
folder and recreating it running the command below in the root of your project.
flutter create -a java .
Author by
LearnToday
Updated on December 21, 2022Comments
-
LearnToday over 1 year
I just noticed my flutter app, the android version is in Kotlin, that is the kotlin directory contains the MainActivity.kt
If I did this, it was a mistake because I don't know any Kotlin.
I would prefer my android app in Java, which is the MainActivity.java under the java folder.
How do I go about changing things so my android app is in Java?
-
John Joe almost 4 yearswhy you need to change your kotlin code? Just change in flutter.
-
LearnToday almost 4 yearsI wanted to use a plugin that is in Java, the scripts for the plugin are in java. For instance I have a file call application.java that I am suppose to place on the same path as MainActivity.java. But I don't have MainActivity.java. What I have is MainActivity.kt. That won't work, will it?
-
Tenfour04 almost 4 yearsIm guessing it will work anyway. Java and Kotlin are interoperable. At runtime there will be no difference between.java and .kt files, besides some irrelevant (to you) meta data, because they both get compiled to bytecode.
-