我正在为Apache Cordova开发Visual Studio工具(在Visual Studio 2015中)。而且我遇到了安装“cordova-plugin-googlemaps”的问题 当我尝试安装插件时,它已安装但有错误(由于它无法添加到平台文件夹并且接近无用。)。请参阅visual studio console下面的错误日志。
------ Ensuring correct global installation of package from source package directory: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\packages\vs-tac
------ Name from source package.json: vs-tac
------ Version from source package.json: 1.0.42
------ Package already installed globally at correct version.
Installing plugin '...\Cordova_Plugins\cordova-plugin-googlemaps-master'
Starting launch process C:\Users\Admin\AppData\Roaming\Microsoft\VisualStudio\MDA\vs-npm\2.14.9\node.exe "C:\Users\Admin\AppData\Roaming\npm\node_modules\vs-tac\pluginInstall.js" --action install --projectSourceDir "...\test\test" --pluginName ...\Cordova_Plugins\cordova-plugin-googlemaps-master --language en-IN --cliVersion "6.5.0" --npmInstallDir "C:\Users\Admin\AppData\Roaming\npm" --parameters "API_KEY_FOR_ANDROID=API_KEY_FOR_ANDROID API_KEY_FOR_IOS=API_KEY_FOR_IOS" --loglevel silly
------ Cordova tools 6.5.0 already installed.
Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "...\Cordova_Plugins\cordova-plugin-googlemaps-master"
Copying plugin "...\Cordova_Plugins\cordova-plugin-googlemaps-master" => "...\test\test\plugins\cordova-plugin-googlemaps"
Calling plugman.install on plugin "...\test\test\plugins\cordova-plugin-googlemaps" for platform "android
Installing "cordova-plugin-googlemaps" for android
Running command: cmd "/s /c "...\test\test\platforms\android\cordova\version.bat""
Command finished with error code 0: cmd /s /c "...\test\test\platforms\android\cordova\version.bat"
Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-googlemaps on android platform only.
Executing script found in plugin cordova-plugin-googlemaps for hook "before_plugin_install": plugins\cordova-plugin-googlemaps\src\before_plugin_install.js
Resolving module name for fs => fs
Resolving module name for path => path
Resolving module name for q => q
Warning: Failed to install 'cordova-plugin-googlemaps':TypeError: Object.keys called on non-object
at Function.keys (native)
at findPreference (...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:170:27)
at ...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:198:43
at Array.forEach (native)
at ...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:197:34
at Array.forEach (native)
at findPreference (...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:171:14)
at ...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:192:25
at Array.forEach (native)
at findPreference (...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:171:14)
C:\Users\Admin\AppData\Roaming\npm\node_modules\vs-tac\node_modules\q\q.js:126
throw e;
^
TypeError: Object.keys called on non-object
at Function.keys (native)
at findPreference (...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:170:27)
at ...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:198:43
at Array.forEach (native)
at ...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:197:34
at Array.forEach (native)
at findPreference (...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:171:14)
at ...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:192:25
at Array.forEach (native)
at findPreference (...\test\test\plugins\cordova-plugin-googlemaps\src\before_plugin_install.js:171:14)
Done
根据日志,我导航到“before_plugin_install.js”文件并查看代码。并且控制台在“ var findPreference = function(xmlData){”这一行的正下方记录了数据(在我的情况下为“xmlData”) 控制台日志的结果位于我附加到此对话的文件中。因为数据大量放在这里并且没有格式化,所以放入文件使每个人都可以更容易地使用在线JSON解析器查看它。
因此在安装时导致错误 您可以从此链接cordova-plugin-googlemaps下载插件表单 我也在插件的官方链接中提出了一个问题,这里是链接Link to issue raised 请参阅此链接以获取附件Link to the document I referred as attachment 非常感谢您的时间,非常感谢。
正如@Frix33建议的那样 谢谢你的回复
以下是您建议的第170行的控制台日志数据。 第一次调用函数时(First Console.log)
[ 'plugin' ]
第二次调用函数时(Second Console.log)
[ '$', 'name', 'js-module', 'description', 'repo', 'issue', 'author', 'license', 'keywords', 'engines', 'hook', 'platform' ]
这是第三个函数调用,它来自行号199,形式为“before_plugin_install.js”,数据xmlData [tagName]是名称“而函数”findPreference“是传递使用“cordova-plugin-googlemaps” 导致第169行出错,其中xmlData为“cordova-plugin-googlemaps”。
Object.keys(xmlData);
XML解析器无法解析我提供的链接的文件数据,因为我添加了一些文本指向每个人访问该位置以供我在谷歌文档中共享的文件中使用的参考。 (我会为其他人添加建议,理解非常感谢你指出这一点)。
编辑(21-04-2018)
这方面取得了一些进展 使用以下命令
通过命令行再次添加插件(通过导航到相应的项目)cordova plugin add cordova-plugin-googlemaps \ --variable API_KEY_FOR_ANDROID="..." \ --variable API_KEY_FOR_IOS="..."
分别用“...”替换我的键
之后开始收到与“PLAY_SERVICES_VERSION”相关的错误,所以应用了以下命令
cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=11.8.0
现在正在关注中 对于类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler“
的对象,”无法获取未知属性'ANDROID_SUPPORT_V4_VERSION'我尝试使用以下命令解决此问题,但错误仍然存在
cordova plugin add cordova-plugin-android-support-v4
它安装了cordova-plugin-android-support-v4(21.0.1)
答案 0 :(得分:0)
插件已安装,但在从visual studio运行时仍然出错
所以我切换到命令行并更新了所有内容
目前使用
cordova 8.0.0
gradle 4.7
视觉工作室仍在完成一些任务 请参考下面的链接,看看我是如何解决这个问题的 Link to GITHUB cordova-googlemaps-plugin issues
如果您发现自己处于同样的混乱状态,请随时发表评论 感谢你们。
注意: - 对于此特定问题,无需解析 cordova-android-play-services-gradle-release 插件。