Just wanted to follow up with this, as I had to change the default language in my Flutter project from Kotlin to Java today, and ran into a little pain point, where I found that running flutter create -i swift -a java .
in my project directory worked, but was causing my project name to change based on whatever directory it was in, and if that directory name was the last value of my "package name" (ie: com.flutter.app and the directory was "app"), this was then throwing a D8: Program type already present:
error when compiling.
This is due to the MainActivity of the original Kotlin src. What I discovered is that I had to (after checking out my source code into this "app" folder that I wanted to use in the package name), first delete this existing android/app/src/main/kotlin
folder AND THEN run the flutter create -i swift -a java .
command.
Note that I didn't have any unique code added to the Kotlin folder, so removal of this folder wasn't a concern.
Hope this helps anyone else experiencing a similar issue.