2

Я чистый разработчик Javascript (angularjs & nodejs) &, не имеющий информации о приложении android или ios. Я следовал учебник nativescipt и создания приложения в nativescipt (угловой) с помощью следующей ссылке: Wiring up Google Maps Nativescript plugin with Angular 2
, но после запуска: tns plugin add nativescript-google-maps-sdk и работает команда tns run android есть исключениеNativeScript nativescript-google-maps-sdk not woking

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. 

Я посетил страница https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0, но не получила никакой информации для устранения этого исключения.

ответ

2

Возможное решение может заключаться в том, чтобы попытаться удалить платформу андроида с помощью tns platform remove android и добавить его снова с помощью tns platform add android.

О nativescript-google-maps-sdk плагин. Используя этот плагин, я создал образец проекта с нуля. Вы можете просмотреть его здесь: NativeScript-Angular-GoogleMaps. Наиболее важной частью является добавление в

NativeScript-Angular-GoogleMaps/app/App_Resources/Android/values/nativescript_google_maps_api.xml Этот фрагмент кода

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

и добавить в конец файла node_modules/nativescript-angular/element-registry.js

эта линия

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

Этот строка поможет NativeScript найти элемент MapView.

+0

спасибо за удивительный образец проекта. , но, как было предложено, я удалил платформу Android и добавлю ее снова. Теперь измените это исключение: 'Не найдено совпадений для com.google.android.gms: play-services-maps: + as no versions of com.google .android.gms: доступны игровые сервисы-карты. ' Я использую эмулятор VSCode и Genymotion –

+1

По умолчанию у Genymotion нет сервиса google play. Для решения этой проблемы существует два варианта: выполнить следующие действия: [Как установить службы Google Play на Genymotion] (http://stackoverflow.com/questions/33344857/preview-google-nexus-5x-6-0-0- api-23-gapps) и настроить службу воспроизведения Google на своем эмуляторе или развернуть приложение на реальном устройстве. –

+1

Достаточно добавить строку 'registerElement ...' в файл' main.ts'. Изменение файла в 'node_modules' не является хорошей идеей, потому что вам придется переделать изменения, если вы переустановите модули. – Leukipp