Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type project.com.project.MainActivity is defined multiple times

Android Application ID conflicts in Kotlin and Java MainActivity classes

Error:

Type project.com.project.MainActivity is defined multiple times 
./project/build/app/intermediates/javac/debug/classes/project/com/project/MainActivity.class,
./project/build/app/tmp/kotlin-classes/debug/project/com/project/MainActivity.class

Both Kotlin and Java MainActivity classes are generated with the flutter run command and both include package project.com.project

MainActivity.class

package project.com.project

public class MainActivity {
   public MainActivity() {
   }
}

MainActivity.kt

package project.com.project

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}

Environment :

Android Studio  4.1.2
Gradle Plugin       4.1.2 
Gradle Version  6.5 
Flutter Version     1.22

Tried in Android Studio :

Build -> Clean Project, 
Build -> Rebuild Project, 
File -> Invalidate Cache Restart 

Tried in Command Line :

flutter clean 
flutter run
rm -Rf ~/.gradle/caches 

The error is still there.

like image 767
ronline Avatar asked Aug 24 '26 16:08

ronline


1 Answers

The conflict is caused by autogenerated Kotlin references in gradle.

Removing all Kotlin entries from gradle config files is sufficient to get the flutter run command back to order

like image 103
ronline Avatar answered Aug 26 '26 06:08

ronline



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!