Skyost / Bonsoir

A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD.
http://bonsoir.skyost.eu/
Other
107 stars 49 forks source link

Error "Duplicate class kotlin. ... ... ..." after after this package added to flutter application #53

Closed Gnitry closed 1 year ago

Gnitry commented 1 year ago

Summary Errors of kind "Duplicate class kotlin....." appears when this library is added to the newly created flutter app.

To Reproduce

flutter create mycast
cd mycast
flutter pub add bonsoir
flutter run

Full log

PS C:\1> flutter create mycast
Creating project mycast...
Resolving dependencies in mycast... (1.3s)
Got dependencies in mycast.
Wrote 122 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev

In order to run your application, type:

  $ cd mycast
  $ flutter run

Your application code is in mycast\lib\main.dart.

PS C:\1> cd .\mycast\
PS C:\1\mycast> flutter pub add bonsoir
Resolving dependencies... 
+ bonsoir 2.2.0+1
+ bonsoir_android 2.2.0
+ bonsoir_darwin 2.2.0+1
+ bonsoir_platform_interface 2.2.0
  collection 1.17.1 (1.17.2 available)
  matcher 0.12.15 (0.12.16 available)
  material_color_utilities 0.2.0 (0.5.0 available)
+ plugin_platform_interface 2.1.4
  source_span 1.9.1 (1.10.0 available)
  test_api 0.5.1 (0.6.0 available)
Changed 5 dependencies!
PS C:\1\mycast> flutter run
Resolving dependencies... 
  collection 1.17.1 (1.17.2 available)
  matcher 0.12.15 (0.12.16 available)
  material_color_utilities 0.2.0 (0.5.0 available)
  source_span 1.9.1 (1.10.0 available)
  test_api 0.5.1 (0.6.0 available)
Got dependencies!
Launching lib\main.dart on SM A336E in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
     Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">[Fix dependency resolution errors](https://github.com/Skyost/Bonsoir/issues/d.android.com/r/tools/classpath-sync-errors)</a>.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s
Running Gradle task 'assembleDebug'...                             17.8s
Exception: Gradle task assembleDebug failed with exit code 1

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.4, on Microsoft Windows [Version 10.0.22621.1778], locale en-US)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc4)
[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.6.2)
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.79.0)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!
Skyost commented 1 year ago

Try to flutter clean before building.

raspberrypisig commented 1 year ago

This worked for me.

https://github.com/flutter/flutter/issues/119247

My system: Windows 11

flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.22000.434], locale en-AU) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0) [√] Android Studio (version 2022.2) [√] VS Code (version 1.77.1) [√] Connected device (2 available) [√] Network resources

Gnitry commented 1 year ago

Try to flutter clean before building.

It doesn't help.

Gnitry commented 1 year ago

This worked for me.

flutter/flutter#119247

My system: Windows 11

flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.22000.434], locale en-AU) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0) [√] Android Studio (version 2022.2) [√] VS Code (version 1.77.1) [√] Connected device (2 available) [√] Network resources

Thanks. It helper to run an app.

Skyost commented 1 year ago

In fact, this error just occured when I tried solving the issue #52 in the example app. I fixed it by upgrading the Kotlin version in android/build.gradle :

buildscript {
    ext.kotlin_version = '1.8.20'

    // ...
}
Gnitry commented 1 year ago

Yes, it helps, thanks a lot