I ran the following command
flutter create --platforms=android,ios my-flutter-app
I then opened Android Studio and ran the app successfully.
Then I created a Firebase project and ran the following commands as specified by the Firebase console:
dart pub global activate flutterfire_cli
flutterfire configure --project=my-firebase-project
flutter pub add firebase_core
When I tried to run again in Android Studio, I got the following:
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
I did no hand-editing of any project file so this was most likely caused by the Firebase-related commands, but how do I find the cause?
After looking at some similar questions on SO, the solution for my issue was different than any of the answers to those questions. I went to settings.gradle
and updated the Kotlin plugin version from 1.7.10 to 1.8.22.
Before:
plugins {
...
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}
After:
plugins {
...
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}