1

Error executing Static Binding Generator: File already exists. This may lead to undesired behavior. Please change the name of one of the extended classes. File:C:\repo\geo\geoapp\platforms\android\app\src\main\java\com\tns\FragmentClass.java Class: com.tns.FragmentClass

I keep getting this error. It started with trying to get the @nativescript/geolocation plug-in to work. It compiled, however the app will crash when the geolocation.watchLocation() method was called. This is what I was trying to fix. I ran the ns clean a few times, rebooted, and delete the c:\users\<username>\.gradle folder. Deleting the .gradle folder worked when I had this error before.

It could be something to do with also using the nativescript-google-maps-sdk plug-in. I believe there is a know issue with the the googlePlayServicesVersion. I tried those options as well without any joy. I am a bit confused to which file I should edit; some mention /app/App_Resources/Android/app.gradle, others app/App_Resources/Android/before-plugins.gradle, I tried both.

Any advise will be much appreciated.

"dependencies": {
    "@nativescript/core": "~8.1.1",
    "@nativescript/theme": "~3.0.1",
    "nativescript-vue": "~2.9.0",
    "vuex": "~3.6.2",
    "@nativescript/geolocation": "7.0.0",
    "@nativescript/directions": "~2.0.1",
    "@nativescript/social-share": "~2.0.4",
    "@triniwiz/nativescript-couchbase": "~1.2.5",
    "@triniwiz/nativescript-toasty": "~4.1.3",
    "@bradmartin/nativescript-urlhandler": "~2.0.1",
    "nativescript-google-maps-sdk" : "3.0.2",
    "nativescript-gif": "~5.0.0"
  },
  "devDependencies": {
    "@nativescript/android": "8.1.1",
    "@nativescript/webpack": "~5.0.0",
    "nativescript-vue-template-compiler": "~2.9.0",
    "@vue/devtools": "^5.3.4",
    "@triniwiz/nativescript-toasty": "~4.1.3",
    "@triniwiz/nativescript-socketio": "4.0.1",
    "nativescript-vue-devtools": "1.5.1"
  }
DV7
  • 51
  • 4

1 Answers1

0

Fixed! In a attempt to narrow down the underlying issue, I created a new project, copied the original code over bit by bit running a ns build android command in between. Turns out to be a few old package references (import Something from 'some-packages') from when I was switching the old tns- packages to the new @nativescript packages. The one package however required a further use of the --force options (ns build android --force) before it started to work.

In term of @nativescript/geolocation vs nativescript-google-maps-sdk part, that was fixed by adding a App_Resources\Android\before-plugins.gradle file with the following contents

android {
    project.ext { 
        googlePlayServicesVersion = "16.+"
    }
    dependencies {
        def googlePlayServicesVersion = project.googlePlayServicesVersion
        compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
    }
}
Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142
DV7
  • 51
  • 4