我是纯粹的Javascript开发人员(angularjs& nodejs)&对android或ios应用程序一无所知。我已经学习了nativescipt的教程,并在以下链接的帮助下创建了nativescipt(angular)中的应用程序:
Wiring up Google Maps Nativescript plugin with Angular 2
但在运行:tns plugin add nativescript-google-maps-sdk并运行命令tns run android
后会出现异常
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,但未获得任何解决此异常的信息。
答案 0 :(得分:3)
可能的解决方法是尝试使用tns platform remove android
删除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
元素。