NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
187 stars 104 forks source link

[@nativescript/geolocation] unable to compile Android version as I get a `Execution failed for task ':app:checkDebugDuplicateClasses'.` #569

Open daniele-andriani-io opened 5 months ago

daniele-andriani-io commented 5 months ago

Hi,

I've been using this in a project and now I am unable to compile this same project for Android. I've tried creating a brand new project to identify the problem and it seems to be linked to this dependency as as soon as I add it I get the following error while running tns run android:

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.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7: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.io.path.ExperimentalPathApi found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0)
Duplicate class kotlin.io.path.PathRelativizer found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0)
Duplicate class kotlin.io.path.PathsKt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0)
Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0)
Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0)
Duplicate class kotlin.jdk7.AutoCloseableKt found in modules jetified-kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7: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>.

The package.json file of my empty project for more details:

{
  "name": "NSEmptyProject",
  "main": "app/app.js",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@nativescript/core": "~8.6.2",
    "@nativescript/theme": "~3.0.2",
    "nativescript-vue": "~2.9.3",
    "@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/camera": "^5.0.15",
    "@nativescript/email": "^2.0.5",
    "@nativescript/imagepicker": "^1.0.9",
    "@nativescript/localize": "^5.0.2",
    "@nativescript/social-share": "^2.0.1",
    "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-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",
    "@nativescript/geolocation": "^8.3.1"
  },
  "devDependencies": {
    "@nativescript/android": "8.5.0",
    "@nativescript/webpack": "~5.0.18",
    "nativescript-vue-template-compiler": "~2.9.3"
  }
}

I might have missed something and would highly appreciate any help on this subject.

Ot92 commented 5 months ago

+1

CatchABus commented 5 months ago

This looks like a kotlin version conflict thing. You can do the following steps to solve this. 1) Enable kotlin using useKotlin configuration 2) Set kotlin version to a newer one

For these, you will need two new gradle files in App_Resources/Android as described here: https://docs.nativescript.org/guide/native-code/android#enable-kotlin

Ot92 commented 5 months ago

This looks like a kotlin version conflict thing. You can do the following steps to solve this.

  1. Enable kotlin using useKotlin configuration
  2. Set kotlin version to a newer one

For these, you will need two new gradle files in App_Resources/Android as described here: https://docs.nativescript.org/guide/native-code/android#enable-kotlin

Lovely!

I added those two respectively and it worked like a charm! Thanks

Screenshot 2024-02-01 at 12 07 42
daniele-andriani-io commented 5 months ago

Dear @CatchABus thanks that got me one step further! Now I have à Execution failed for task ':app:mergeExtDexDebug'. error :face_exhaling:

CatchABus commented 5 months ago

Dear @CatchABus thanks that got me one step further! Now I have à Execution failed for task ':app:mergeExtDexDebug'. error 😮‍💨

Your error mentions dex so in your case, there might also be the need to enable multidex. In your app.gradle, ensure multiDexEnabled is set in android.defaultConfig.

android {
  defaultConfig {
    ...
    multiDexEnabled true
  }
}
daniele-andriani-io commented 5 months ago

Dear @CatchABus thanks that got me one step further! Now I have à Execution failed for task ':app:mergeExtDexDebug'. error 😮‍💨

Your error mentions dex so in your case, there might also be the need to enable multidex. In your app.gradle, ensure multiDexEnabled is set in android.defaultConfig.

android {
  defaultConfig {
    ...
    multiDexEnabled true
  }
}

Thanks, I've found that. It must be a problem in my project because a project from scratch with the same dependencies will build. Sooo back to selecting files until I find what is wrong :sweat:

pichurichko commented 5 months ago

@CatchABus created app from scratch, added link to library @nativescript/geolocation, made all changes described in the link: https://docs.nativescript.org/guide/native-code/android#enable-kotlin

Building release version of the app

ns build android --bundle --release --key-store-path "path" --key-store-password pwd --key-store-alias alias --key-store-alias-password password --env.uglify --env.aot

produces such logs, but .apk file created:

e: /Users/user/.gradle/caches/transforms-3/87784638ab761edd0eee6786a12d37af/transformed/jetified-play-services-location-21.1.0/jars/classes.jar!/META-INF/third_party.kotlin.kotlinx_coroutines.google.java.kotlinx.coroutines.google_context_interceptor.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/transforms-3/87784638ab761edd0eee6786a12d37af/transformed/jetified-play-services-location-21.1.0/jars/classes.jar!/META-INF/java.com.google.android.gms.libs.identity_identity.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/transforms-3/87784638ab761edd0eee6786a12d37af/transformed/jetified-play-services-location-21.1.0/jars/classes.jar!/META-INF/third_party.kotlin.kotlinx_atomicfu_kotlinx_atomicfu-jvm.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-parcelize-runtime/1.9.10/413be2a8afc215889d5a1698466bc034edfcc7b6/kotlin-parcelize-runtime-1.9.10.jar!/META-INF/parcelize-runtime.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-android-extensions-runtime/1.9.10/f389651eb00395324af2c2011d7c171a160073a3/kotlin-android-extensions-runtime-1.9.10.jar!/META-INF/kotlin-android-extensions-runtime.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.10/72812e8a368917ab5c0a5081b56915ffdfec93b7/kotlin-stdlib-1.9.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.10/72812e8a368917ab5c0a5081b56915ffdfec93b7/kotlin-stdlib-1.9.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.10/72812e8a368917ab5c0a5081b56915ffdfec93b7/kotlin-stdlib-1.9.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.9.10/dafaf2c27f27c09220cee312df10917d9a5d97ce/kotlin-stdlib-common-1.9.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

Last version that works without problems and other actions is 21.0.1:

project.ext { googlePlayServicesVersion = "21.0.1" }

CatchABus commented 5 months ago

@pichurichko Have you updated your CLI to 8.6?

pichurichko commented 5 months ago

@pichurichko Have you updated your CLI to 8.6?

Thx for your reply echo 'y' | npx nativescript-envinfo output:

OS: macOS 14.1.2
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Shell: /bin/zsh
node: 20.3.0
npm: 9.6.7
nativescript: 8.6.5

# android
java: 15.0.2
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: 15.1/15C65
cocoapods: 1.14.3
python: 2.7.18
python3: 3.9.6
ruby: 2.7.4
platforms: 
  - DriverKit 23.2
  - iOS 17.2
  - macOS 14.2
  - tvOS 17.2
  - watchOS 10.2

Dependencies

"dependencies": {
  "@angular/animations": "~16.2.0",
  "@angular/common": "~16.2.0",
  "@angular/compiler": "~16.2.0",
  "@angular/core": "~16.2.0",
  "@angular/forms": "~16.2.0",
  "@angular/platform-browser": "~16.2.0",
  "@angular/platform-browser-dynamic": "~16.2.0",
  "@angular/router": "~16.2.0",
  "@nativescript/angular": "^16.0.0",
  "@nativescript/core": "~8.6.0",
  "@nativescript/geolocation": "^8.3.1",
  "@nativescript/theme": "~3.0.2",
  "rxjs": "~7.8.0",
  "zone.js": "~0.13.0"
},
"devDependencies": {
  "@angular-devkit/build-angular": "~16.2.0",
  "@angular/compiler-cli": "~16.2.0",
  "@nativescript/android": "8.6.2",
  "@nativescript/types": "~8.6.0",
  "@nativescript/webpack": "~5.0.18",
  "@ngtools/webpack": "~16.2.0",
  "typescript": "~5.1.6"
}
CatchABus commented 5 months ago

@pichurichko Have you updated your CLI to 8.6?

Thx for your reply echo 'y' | npx nativescript-envinfo output:

OS: macOS 14.1.2
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Shell: /bin/zsh
node: 20.3.0
npm: 9.6.7
nativescript: 8.6.5

# android
java: 15.0.2
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: 15.1/15C65
cocoapods: 1.14.3
python: 2.7.18
python3: 3.9.6
ruby: 2.7.4
platforms: 
  - DriverKit 23.2
  - iOS 17.2
  - macOS 14.2
  - tvOS 17.2
  - watchOS 10.2

Dependencies

"dependencies": {
  "@angular/animations": "~16.2.0",
  "@angular/common": "~16.2.0",
  "@angular/compiler": "~16.2.0",
  "@angular/core": "~16.2.0",
  "@angular/forms": "~16.2.0",
  "@angular/platform-browser": "~16.2.0",
  "@angular/platform-browser-dynamic": "~16.2.0",
  "@angular/router": "~16.2.0",
  "@nativescript/angular": "^16.0.0",
  "@nativescript/core": "~8.6.0",
  "@nativescript/geolocation": "^8.3.1",
  "@nativescript/theme": "~3.0.2",
  "rxjs": "~7.8.0",
  "zone.js": "~0.13.0"
},
"devDependencies": {
  "@angular-devkit/build-angular": "~16.2.0",
  "@angular/compiler-cli": "~16.2.0",
  "@nativescript/android": "8.6.2",
  "@nativescript/types": "~8.6.0",
  "@nativescript/webpack": "~5.0.18",
  "@ngtools/webpack": "~16.2.0",
  "typescript": "~5.1.6"
}

It's as if your kotlin version set is disregarded. NativeScript android runtime uses 1.7.1 by default but can be overridden by setting kotlinVersion in your gradle files. This is how it's done in runtime: https://github.com/NativeScript/android/blob/main/test-app/build.gradle#L135 I suggest ensuring steps for setting kotlin version are followed properly and hitting ns clean and build again. If problem persists, feel free to ask help in discord channel.

By the way, this is Google being Google. More people had this problem with newer play-services versions and this one had a problem with location specifically: https://www.reddit.com/r/flutterhelp/comments/17pzika/comment/k9j2tc3/?utm_source=share&utm_medium=web2x&context=3

pichurichko commented 5 months ago

@CatchABus if i would do anything wrong, my debug run would not be ok. That logs (above) are appearing only for release build.

1) My debug run is OK 2) My release build is not OK

And I assume that the best recommendation for now is to use 21.0.1 version of the googlePlayServicesVersion in project.ext values.

Ot92 commented 5 months ago

Interestingly enough, I am now getting a :app:mergeExtDexDebug and ERROR:D8: com.android.tools.r8.kotlin.H

multiDexEnabled true is the setting in my android.defaultConfig

echo 'y' | npx nativescript-envinfo output:

OS: macOS 11.6.5
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: /bin/bash
node: 18.19.0
npm: 10.2.3
nativescript: 8.6.5

# android
java: 11.0.14.1
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found
daniele-andriani-io commented 5 months ago

Interestingly enough, I am now getting a :app:mergeExtDexDebug and ERROR:D8: com.android.tools.r8.kotlin.H

multiDexEnabled true is the setting in my android.defaultConfig

echo 'y' | npx nativescript-envinfo output:

OS: macOS 11.6.5
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: /bin/bash
node: 18.19.0
npm: 10.2.3
nativescript: 8.6.5

# android
java: 11.0.14.1
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

I'm having the exact same code error with the following:

OS: macOS 14.0
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Shell: /bin/zsh
node: 21.4.0
npm: 10.2.4
nativescript: 8.6.5

# android
java: 17.0.9
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: 15.2/15C500b
cocoapods: 1.14.0
python: 2.7.17
python3: 3.11.6
ruby: 2.7.8
platforms: 
  - DriverKit 23.2
  - iOS 17.2
  - macOS 14.2
  - tvOS 17.2
  - visionOS 1.0
  - watchOS 10.2

Dependencies

"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"
}

But again, if I create a project from scratch with the same dependencies, it compiles. So I'm wondering if there is something else in my code generating this error.

Ot92 commented 5 months ago

Interestingly enough, I am now getting a :app:mergeExtDexDebug and ERROR:D8: com.android.tools.r8.kotlin.H multiDexEnabled true is the setting in my android.defaultConfig echo 'y' | npx nativescript-envinfo output:

OS: macOS 11.6.5
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: /bin/bash
node: 18.19.0
npm: 10.2.3
nativescript: 8.6.5

# android
java: 11.0.14.1
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

I'm having the exact same code error with the following:

OS: macOS 14.0
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Shell: /bin/zsh
node: 21.4.0
npm: 10.2.4
nativescript: 8.6.5

# android
java: 17.0.9
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: 15.2/15C500b
cocoapods: 1.14.0
python: 2.7.17
python3: 3.11.6
ruby: 2.7.8
platforms: 
  - DriverKit 23.2
  - iOS 17.2
  - macOS 14.2
  - tvOS 17.2
  - visionOS 1.0
  - watchOS 10.2

Dependencies

"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"
}

But again, if I create a project from scratch with the same dependencies, it compiles. So I'm wondering if there is something else in my code generating this error.

Hello, I solved this by downgrading NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION to NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION=7.3.0 in my gradle.properties

daniele-andriani-io commented 5 months ago

@Ot92 many thanks, that helped a lot!

Also in my case I've had other issues with a One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts error, which I've resolved by adding a targetSdkVersion 30 to my App_Resources/Android/app.gradle file.

CatchABus commented 5 months ago

@Ot92 many thanks, that helped a lot!

Also in my case I've had other issues with a One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts error, which I've resolved by adding a targetSdkVersion 30 to my App_Resources/Android/app.gradle file.

You might be needing exported property: https://github.com/NativeScript/nativescript-app-templates/blob/main/shared-mobile/App_Resources/Android/src/main/AndroidManifest.xml#L31 These further problems don't seem to be related to geolocation anymore so let's keep discussions in discord.

brooklax commented 5 months ago

This looks like a kotlin version conflict thing. You can do the following steps to solve this.

  1. Enable kotlin using useKotlin configuration
  2. Set kotlin version to a newer one

For these, you will need two new gradle files in App_Resources/Android as described here: https://docs.nativescript.org/guide/native-code/android#enable-kotlin

Would making this change in any way affect app compatibility with older versions of Android?

I made this change and I have an Android 11 user reporting that the Play Store now shows this message when they try to download the app: This app isn't available for your device because it was made for an older version of Android.

I'm going to try an older kotlin version (1.8.22) and see if it makes a difference as the app seems to build fine with still, just waiting for the user to test again.

EDIT:

Apparently it's a Play Store bug https://stackoverflow.com/questions/75515890/this-app-isnt-available-for-your-device-because-it-was-made-for-an-older-versio

slejnej commented 1 month ago

Hello.

I've tried all of the bove and still get the error ERROR:D8: com.android.tools.r8.kotlin.H Execution failed for task ':app:mergeExtDexDebug'. null Tried with kotlin 1.8.22, 1.9.10 (created the gradle.properties file, updated the before-plugin.gradle, also without kotlin and always same result as soon as I add "@nativescript/geolocation": "^8.3.1".

My package.json:

"dependencies": {
    "@angular/animations": "~17.3.0",
    "@angular/common": "~17.3.0",
    "@angular/compiler": "~17.3.0",
    "@angular/core": "~17.3.0",
    "@angular/forms": "~17.3.0",
    "@angular/platform-browser": "~17.3.0",
    "@angular/platform-browser-dynamic": "~17.3.0",
    "@angular/router": "~17.3.0",
    "@nativescript-community/insomnia": "^2.0.2",
    "@nativescript-community/perms": "^2.3.3",
    "@nativescript/angular": "^17.0.0",
    "@nativescript/core": "~8.7.0",
    "@nativescript/geolocation": "^8.3.1",
    "@nativescript/theme": "~3.0.2",
    "nativescript-ui-gauge": "^15.2.3",
    "rxjs": "~7.8.0",
    "zone.js": "~0.14.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~17.3.0",
    "@angular/compiler-cli": "~17.3.0",
    "@nativescript/android": "8.7.0",
    "@nativescript/types": "~8.7.0",
    "@nativescript/webpack": "~5.0.19",
    "@ngtools/webpack": "~17.3.0",
    "node-sass": "^9.0.0",
    "typescript": "~5.4.0"
  }

And app.gradle:

dependencies {
//  implementation 'androidx.multidex:multidex:2.0.1'
}

android {
  compileSdkVersion 34
  buildToolsVersion "34"
  // ndkVersion ""

  defaultConfig {
    applicationId = "xxx"
    minSdkVersion 23
    targetSdkVersion 34

    // Version Information
    versionCode 1
    versionName "1.0.0"

    generatedDensities = []

    multiDexEnabled true
    ndk {
      abiFilters.clear()
      abiFilters "x86_64", "x86", "arm64-v8a", "armeabi-v7a"
    }
    vectorDrawables.useSupportLibrary = true
  }

  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}```

Output of `nativescript-envinfo`:
```yaml
OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700K
Shell: /usr/bin/zsh
node: 18.18.0 (tried qith node 20 also)
npm: 9.8.1
nativescript: 8.7.2

# android
java: 11.0.23
ndk: Not Found
apis: 30, 31, 33, 34
build_tools: 30.0.3, 34.0.0
system_images: 
  - android-33 | Google Play Intel x86 Atom_64

# ios
xcode: Not Found
cocoapods: Not Found
python: 3.8.10
python3: 3.8.10
ruby: Not Found
platforms: Not Found
eikaramba commented 6 days ago

exact same problem NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION=7.3.0 works

OS: Windows 10 10.0.19045
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Shell: Not Found
node: 20.9.0
npm: 10.1.0
nativescript: Not Found

# android
java: Not Found
ndk: Not Found
apis: 28, 29, 31, 32, 33, 34
build_tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0, 33.0.0, 33.0.1, 34.0.0
system_images:
  - android-33 | Google Play Intel x86_64 Atom

# ios
xcode: Not Found
cocoapods: Not Found
python: Not Found
python3: Not Found
ruby: Not Found
platforms: Not Found

Dependencies

"dependencies": {
  "@klippa/nativescript-http": "^3.0.4",
  "@nativescript-community/ui-material-bottomnavigationbar": "^7.2.60",
  "@nativescript-community/ui-svg": "^0.2.0",
  "@nativescript-community/universal-links": "^3.0.1",
  "@nativescript/core": "^8.7.2",
  "@nativescript/firebase-core": "^3.3.1",
  "@nativescript/firebase-crashlytics": "^3.3.1",
  "@nativescript/firebase-messaging": "^3.3.1",
  "@nativescript/firebase-messaging-core": "^3.3.1",
  "@nativescript/iqkeyboardmanager": "^2.1.1",
  "@nativescript/local-notifications": "^6.2.0",
  "@nativescript/theme": "^3.0.2",
  "@nstudio/nativescript-barcodescanner": "^5.0.1",
  "@triniwiz/nativescript-toasty": "^4.1.3",
  "cross-env": "^7.0.3",
  "dayjs": "^1.11.11",
  "dotenv": "^16.4.5",
  "nativescript-apple-sign-in": "^2.0.0",
  "nativescript-videoplayer": "^5.0.1",
  "svelte-native": "^1.0.27",
  "sveltekit-i18n": "^2.4.2",
  "url-parse": "^1.5.10",
  "url-search-params-polyfill": "^8.2.5"
},
"devDependencies": {
  "@nativescript/android": "^8.7.0",
  "@nativescript/ios": "^8.7.2",
  "@nativescript/tailwind": "^2.1.0",
  "@nativescript/types": "^8.7.0",
  "@nativescript/webpack": "^5.0.21",
  "convert-svg-to-png": "^0.6.4",
  "postcss": "^8.4.39",
  "postcss-loader": "^8.1.1",
  "sass": "^1.77.6",
  "svelte": "^4.2.18",
  "svelte-loader": "^3.2.3",
  "svelte-native-preprocessor": "^1.0.0",
  "svelte-preprocess": "^6.0.2",
  "tailwindcss": "^3.4.4",
  "typescript": "^5.5.3"
}