【问题标题】:NativeScript: @nativescript/geolocation vs nativescript-google-maps-sdkNativeScript:@nativescript/geolocation 与 nativescript-google-maps-sdk
【发布时间】:2021-12-13 23:32:38
【问题描述】:

执行静态绑定生成器时出错:文件已存在。这可能导致不良行为。 请更改其中一个扩展类的名称。 文件:C:\repo\geo\geoapp\platforms\android\app\src\main\java\com\tns\FragmentClass.java 类:com.tns.FragmentClass

我不断收到此错误。它首先尝试让@nativescript/geolocation 插件工作。它已编译,但是当调用 geolocation.watchLocation() 方法时应用程序将崩溃。这就是我试图解决的问题。我运行了几次ns clean,重新启动并删除了c:\users\<username>\.gradle 文件夹。当我之前遇到此错误时,删除 .gradle 文件夹有效。

这可能与使用nativescript-google-maps-sdk 插件有关。我相信googlePlayServicesVersion 存在一个已知问题。我也尝试了这些选项,没有任何喜悦。我对应该编辑哪个文件有点困惑;有人提到/app/App_Resources/Android/app.gradle,有人提到app/App_Resources/Android/before-plugins.gradle,我都试过了。

任何建议将不胜感激。

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

【问题讨论】:

    标签: nativescript nativescript-vue nativescript-plugin


    【解决方案1】:

    已修复!为了缩小潜在问题的范围,我创建了一个新项目,逐位复制原始代码,并在其间运行 ns build android 命令。结果是我将旧的 tns- 包切换到新的 @nativescript 包时的一些旧包引用 (import Something from 'some-packages')。然而,一个包需要进一步使用 --force 选项 (ns build android --force) 才能开始工作。

    @nativescript/geolocation vs nativescript-google-maps-sdk 部分而言,已通过添加 App_Resources\Android\before-plugins.gradle 文件修复内容如下

    android {
        project.ext { 
            googlePlayServicesVersion = "16.+"
        }
        dependencies {
            def googlePlayServicesVersion = project.googlePlayServicesVersion
            compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-13
      • 2020-02-07
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      相关资源
      最近更新 更多