2

I am pure Javascript developer (angularjs & nodejs) & having no knowledge on android or ios app. I have followed tutorial of nativescipt and was creating an app in nativescipt(angular) with help of following link: Wiring up Google Maps Nativescript plugin with Angular 2
but after running : tns plugin add nativescript-google-maps-sdk and on running command tns run android there is an exception

    D:\ts\app\sample-Groceries>tns run android
    Executing before-prepare hook from D:\ts\app\sample-Groceries\hooks\before-prepare\nativescript-dev-typescript.js
    Found peer TypeScript 1.8.10
    Project successfully prepared
    WARNING: The file: D:\ts\app\sample-Groceries\node_modules\nativescript-google-maps-sdk\platforms\android\AndroidManifest.xml is depricated, you can read more about what will be the expected plugin structure here: https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0
    WARNING: The file: D:\ts\app\sample-Groceries\node_modules\nativescript-google-maps-sdk\platforms\android\res\values\nativescript_google_maps_api.xml is depricated, you can read more about what will be the expected plugin structure here: https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0

    :config phase:  createDefaultIncludeFiles
            +found plugins: nativescript-google-maps-sdk
     {
                  "F0" {
                    dimension "nativescriptgooglemapssdk"
                  }
                }
    }Renaming plugin directory to flavor name: D:\ts\app\sample-Groceries\platforms\android\src\nativescript-google-maps-sdk
-> D:\ts\app\sample-Groceries\platforms\android\src\F0
            +found plugins: tns-core-modules-widgets
     {
                  "F1" {
                    dimension "tnscoremoduleswidgets"
                  }
                } }Renaming plugin directory to flavor name: D:\ts\app\sample-Groceries\platforms\android\src\tns-core-modules-widgets
 D:\ts\app\sample-Groceries\platforms\android\src\F1

    :config phase:  createPluginsConfigFile
             Creating product flavors include.gradle file in D:\ts\app\sample-Groceries\platforms\android/configurations folder...

    :config phase:  pluginExtend
            +applying configuration from: D:\ts\app\sample-Groceries\platforms\android\configurations\include.gradle
            +applying configuration from: D:\ts\app\sample-Groceries\platforms\android\configurations\nativescript-google-maps-sdk\include.gradle
            +applying configuration from: D:\ts\app\sample-Groceries\platforms\android\configurations\tns-core-modules-widgets\include.gradle

    :config phase:  copyAarDependencies

    :config phase:  addAarDependencies
            +adding dependency: D:\ts\app\sample-Groceries\platforms\android\libs\aar\widgets-release.aar

    FAILURE: Build failed with an exception.

I have visited page https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0 but didn't get any info to resolve this exception.

Community
  • 1
  • 1
durgesh rao
  • 93
  • 1
  • 5

1 Answers1

4

Possible solution could be to to try removing android platform with tns platform remove android and to add it again with tns platform add android.

About nativescript-google-maps-sdk plugin. I have created sample project from scratch using this plugin. You could review it here: NativeScript-Angular-GoogleMaps. The most important part is to add in

NativeScript-Angular-GoogleMaps/app/App_Resources/Android/values/nativescript_google_maps_api.xml this code snippet

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="nativescript_google_maps_api_key">API_KEY</string>
</resources>

and to add in the end of the file node_modules/nativescript-angular/element-registry.js

this line

registerElement("mapView", function () { return require("nativescript-google-maps-sdk").MapView; });

This line will help NativeScript to found MapView element.

Nikolay Tsonev
  • 1,919
  • 3
  • 16
  • 29
  • thanks for awesome sample project . but as suggested I have remove android platform and add it again , Now exception change into this: `Could not find any matches for com.google.android.gms:play-services-maps:+ as no versions of com.google.android.gms:play-services-maps are available.` I am using VSCode and Genymotion emulator – durgesh rao May 16 '16 at 19:46
  • 1
    By default Genymotion do not have google play service. There are two options to solve this problem: to follow those:[How to install Google Play Services on Genymotion](http://stackoverflow.com/questions/33344857/preview-google-nexus-5x-6-0-0-api-23-gapps) steps and to config google play service on your emulator, or to deploy your app on real device. – Nikolay Tsonev May 17 '16 at 05:56
  • 1
    It is sufficient to add the line `registerElement...` to the file `main.ts`. Changing a file in `node_modules` is not a good idea because you would have to redo the changes if you re-install the modules. – Leukipp Apr 25 '17 at 09:08