I've been working on an application that I got from a leaving colleague and I am new to NativeScript.
When trying to run an app on an Android emulator using the ns run android
command I get the following error:
Execution failed for task ':app:checkDebugDuplicateClasses'.
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
I've tried the following:
platforms/android/build.gradle
file following other posts on this matter...The ns run ios
works fine, so I'm guessing this is something Java/Android related. Any help would be highly appreciated.
My package.json
file if this can help:
{
"description": "NativeScript Application",
"main": "app/app.js",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"version": "7.0.1",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@finanzritter/nativescript-share-file": "^2.0.1",
"@nativescript-community/sentry": "^4.6.12",
"@nativescript-community/ui-canvas": "^4.0.50",
"@nativescript-community/ui-collectionview": "^4.0.29",
"@nativescript-community/ui-image": "4.3.6",
"@nativescript-community/ui-material-bottom-navigation": "^7.0.24",
"@nativescript-community/ui-material-core": "^7.0.24",
"@nativescript-community/ui-material-tabs": "^7.0.24",
"@nativescript-community/ui-pager": "^13.0.2",
"@nativescript-community/ui-pulltorefresh": "^2.5.3",
"@nativescript-community/ui-webview": "^1.4.4",
"@nativescript-community/universal-links": "^2.0.7",
"@nativescript/background-http": "^6.0.0",
"@nativescript/camera": "^5.0.15",
"@nativescript/core": "~8.5.9",
"@nativescript/email": "^2.0.5",
"@nativescript/firebase-analytics": "^3.1.0",
"@nativescript/firebase-core": "^3.1.0",
"@nativescript/firebase-messaging": "^3.1.0",
"@nativescript/geolocation": "^8.1.0",
"@nativescript/imagepicker": "^1.0.9",
"@nativescript/localize": "^5.0.2",
"@nativescript/social-share": "^2.0.1",
"@nativescript/theme": "~3.0.2",
"buffer": "^6.0.3",
"moment": "^2.29.0",
"nativescript-barcodescanner": "^4.1.2",
"nativescript-imagecropper": "^4.0.1",
"nativescript-phone": "^2.0.0",
"nativescript-plugin-universal-links": "^2.0.0",
"nativescript-ui-calendar": "^7.0.2",
"nativescript-ui-chart": "^8.0.2",
"nativescript-ui-listview": "^9.1.0",
"nativescript-vue": "~2.9.3",
"nativescript-vue-multi-drawer": "^0.0.4",
"nativescript-websockets": "^1.5.6",
"vue": "^2.6.12",
"vue-template-compiler": "^2.6.12",
"vuelidate": "^0.7.6",
"vuex": "^3.5.1"
},
"devDependencies": {
"@nativescript/android": "8.6.2",
"@nativescript/ios": "~8.6.1",
"@nativescript/webpack": "~5.0.18",
"nativescript-vue-template-compiler": "~2.9.3"
},
"gitHead": "-",
"readme": "NativeScript Application"
}
[Update 2024-02-01] In the meantime I've been able to reduce the culprite to 2 dependencies:
Posting the answer here in case it can help others:
I've had to add the following line in the App_Resources/Android/gradle.properties
(in my case I needed to create it first):
useKotlin=true
and add the following in the App_Resources/Android/before-plugins.gradle
file:
project.ext {
kotlinVersion = "1.9.10"
}
Source: GitHub