Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 #7866

Open
1 of 3 tasks
mattiLeBlanc opened this issue Feb 4, 2025 · 17 comments
Labels
platform: android type: bug A confirmed bug report

Comments

@mattiLeBlanc
Copy link

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/android: 7.0.1
@capacitor/ios: 7.0.1

Installed Dependencies:

@capacitor/ios: not installed
@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/android: 7.0.1

[success] Android looking great! 👌

Other API Details

npm 8.19.1
node: v20.14.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

I am trying to build my Angular Capacitor Project for Android and I am running in an error

Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotl
Image

I am pretty new to this and not really sure what to do.
I found this https://gist.github.com/danielcshn/7aa57155d766d46c043fde015f054d40 and tried adding the implementation line to my build.gradle (module) file but to no avail.

How do I fix this

Expected Behavior

Build the project

Project Reproduction

not possible

Additional Information

No response

@SteliosMoch
Copy link

Same exact problem on my app when i migrate to capacitor 7. Also tried the example blank app and i got the same results.

@jcesarmobile jcesarmobile added the needs reproduction needs reproducible example to illustrate the issue label Feb 4, 2025
Copy link

ionitron-bot bot commented Feb 4, 2025

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.
Please see the Contributing Guide for how to create a Sample App.
Thanks! Ionitron 💙

@ionitron-bot ionitron-bot bot removed the triage label Feb 4, 2025
@Ionitron Ionitron added needs reply needs reply from the user and removed needs reply needs reply from the user labels Feb 4, 2025
@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Feb 4, 2025
@Ionitron Ionitron removed the needs reply needs reply from the user label Feb 4, 2025
@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Feb 4, 2025
@crobinson-expl
Copy link

I'm not the original reporter, but I created a minimal sample app that demonstrates this issue: https://github.com/[crobinson-expl/vue-capacitor](https://github.com/crobinson-expl/vue-capacitor).

Here's how I created it:

  1. npm create vue@latest
  2. Follow prompts to add everything but jsx and prettier and use Cypress for e2e testing
  3. cd vue-capacitor
  4. npm i -D @capacitor/cli
  5. npm i @capacitor/android
  6. npm run build
  7. npx cap init
  8. Follow prompts to provide name and app ID
  9. npx cap add android
  10. npx cap open android
  11. Clean Project then Rebuild Project from Build menu

@Ionitron Ionitron removed the needs reply needs reply from the user label Feb 4, 2025
@jcesarmobile jcesarmobile added platform: android type: bug A confirmed bug report labels Feb 4, 2025
Copy link

ionitron-bot bot commented Feb 4, 2025

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

@jcesarmobile jcesarmobile removed the needs reproduction needs reproducible example to illustrate the issue label Feb 4, 2025
@jcesarmobile
Copy link
Member

As workaround you can set the value of androidxAppCompatVersion to '1.6.1' in variables.gradle file.

Not sure why it fails on the capacitor-cordova-android-plugins module if it doesn't use kotlin.

@crobinson-expl
Copy link

As workaround you can set the value of androidxAppCompatVersion to '1.6.1' in variables.gradle file.

Not sure why it fails on the capacitor-cordova-android-plugins module if it doesn't use kotlin.

Thanks, that fixed the error for me!

crobinson-expl added a commit to crobinson-expl/vue-capacitor that referenced this issue Feb 4, 2025
@muuvmuuv

This comment has been minimized.

@mattiLeBlanc
Copy link
Author

I'm not the original reporter, but I created a minimal sample app that demonstrates this issue: [https://github.com/crobinson-expl/vue-capacitor](https://github.com/%5Bcrobinson-expl/vue-capacitor%5D(https://github.com/crobinson-expl/vue-capacitor)).

Here's how I created it:

  1. npm create vue@latest
  2. Follow prompts to add everything but jsx and prettier and use Cypress for e2e testing
  3. cd vue-capacitor
  4. npm i -D @capacitor/cli
  5. npm i @capacitor/android
  6. npm run build
  7. npx cap init
  8. Follow prompts to provide name and app ID
  9. npx cap add android
  10. npx cap open android
  11. Clean Project then Rebuild Project from Build menu

Thanks for that. I was about to create simple test app with Angular and install Capacitor and share the repo. I will first see if the feedback coming back after your post will resolve the issue.

@mattiLeBlanc

This comment has been minimized.

@mattiLeBlanc
Copy link
Author

Actually one complication I get when downgrading androidxAppCompatVersion to 1.6.1 is that my Angular app is throwing a javascript error when I run my app in a Virtual Device. I haven't found out yet how to see any javascript console messages in Android Studio (does anyone have suggestion?).
But when I set androidxAppCompatVersion back to 1.7.0 I can preview the app again.
I will create a repo demonstrating this issue.

@mattiLeBlanc
Copy link
Author

My test repo: https://github.com/mattiLeBlanc/capacitor7-issue.
Run:

  • run npm install
  • have Android Studio installed
  • run npx cap open android to run in Android Studio
  • run app on a virtual device and you should see the test app:
Image

Now if you hit Make Project you get the duplicate class error:

Image

Now I downgrade androidxAppCompatVersion to 1.6.1.
Build is now working fine and when I run the test app, Angular app is working.

However when I do this our production app, I seem to get a Javascript error which stops Angular from loading. But since I haven't been able to see the console.log I don't really know why the Angular app is not loading. I will investigate further.

If any one knows how to get the javascript console message displayed in LogCat, please share. That would help me a lot.

@crobinson-expl
Copy link

Actually one complication I get when downgrading androidxAppCompatVersion to 1.6.1 is that my Angular app is throwing a javascript error when I run my app in a Virtual Device. I haven't found out yet how to see any javascript console messages in Android Studio (does anyone have suggestion?). But when I set androidxAppCompatVersion back to 1.7.0 I can preview the app again. I will create a repo demonstrating this issue.

I have had success using edge://inspect or chrome://inspect to view the browser dev tools when debugging the app in Android Studio. This works regardless of whether the app is running in an emulator or on an actual device.

@mattiLeBlanc
Copy link
Author

mattiLeBlanc commented Feb 4, 2025

@crobinson-expl How do you execute chrome://inspect. When I preview the app I am not seeing any address bar to put this command in. I am pretty new to Android Studio so I am still figuring out how to debug.

UPDATE:
I found out that using chrome inspect, I can connect to my virtual device so I am getting JS errors now, YAY!

@PymZoR
Copy link

PymZoR commented Feb 11, 2025

Found another workaround, no idea which one is best or the possible side effect of this one.
I added to my build.gradle the following to force resolution on latest kotlin version :

allprojects {
    ...
    configurations.all {
        resolutionStrategy.force(
            "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}",
            "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlinVersion}",
            "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}",
            "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion}"
        )
    }
}

and added in variables.gradle

ext {
    ...
    kotlinVersion = '1.9.25'
}

@cesterlizi
Copy link

Hi, i have se same problem.

How to reproduce

$ npm init @capacitor/app@latest
$ cd capacitor-app-solo/
$ npm i
$ npm run build
$ npm i -D @capacitor/cli
$ npx cap init
$ npm i --save @capacitor/android
$ npx cap add android
$ npx cap sync
$ npx cap open android

error on android studio

> Task :capacitor-cordova-android-plugins:checkDebugAndroidTestDuplicateClasses FAILED
Execution failed for task ':capacitor-cordova-android-plugins:checkDebugAndroidTestDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.io.path.ExperimentalPathApi found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathRelativizer found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathsKt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.jdk7.AutoCloseableKt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk7-1.6.21.jar -> kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules kotlin-stdlib-1.8.22.jar -> kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.6.21.jar -> kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)

versions

$ npx cap --version
7.0.1
Android Studio Ladybug Feature Drop | 2024.2.2 Patch 1
Build #AI-242.23726.103.2422.13016713, built on February 5, 2025
Runtime version: 21.0.5+-12932927-b750.29 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 15.2
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 16
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
  i18n.locale=

@kgoubar
Copy link

kgoubar commented Feb 20, 2025

hi @cesterlizi , I'm having the same issue as well , any progress about this issue ?
thanks

@co-dax

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android type: bug A confirmed bug report
Projects
None yet
Development

No branches or pull requests

10 participants