I am working on Visual Studio tool for Apache Cordova(In Visual Studio 2015). And I am stuck with the issue with installing "cordova-plugin-googlemaps".
When I try to install the plugin it get's installed but with error(Due to which it can't get added to platform folder and close to useless.). Please refer the error log below from 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
Based on the logs I navigated to the "before_plugin_install.js" file and had the look at the code. And console logged the data(In my case "xmlData") just below the line "var findPreference = function(xmlData) {"
And the result from the console log is in the file I am attaching to this conversation. Because the data is in large amount to place here and it is not formatted as well so putting into file make it easier for everyone to have a look at it with online JSON parsers.
- Now after all that I ended up at this that when the code enters with the function findPreference function for the first time it has the data as first marked as "1" in the file I attached for more convenience search for this "==>" in the file and you find the place I am referring too.(NOTE:- With this data the function enters the switch with case "plugin")
- Once the code enters the case plugin it calls the function again findPreference function with the data "marked as "2" in the file I attached(search for this "==>" in the file)".
- The program enter the function for the third time from
results = Object.assign(findPreference(node), results);
which is default condition for the switch in "findPreference function" "before_plugin_install.js" when ii get this "cordova-plugin-googlemaps" from foreach marked as "right_here_1" in the document attached. - Now from there the program enters the function findPreference with the value "cordova-plugin-googlemaps" and when it reaches "var keys = Object.keys(xmlData);" line in the code inside function findPreference it fails as it is not the object.
Hence causing the error while installation.
You can download the plugin form this link cordova-plugin-googlemaps.
I Have also raised an issue in plugin's official link here is the link Link to issue raised.
Please refer this link for attached file Link to the document I referred as attachment.
Thank you very much for your time really appreciated.
As @Frix33 suggested
Thank you for you reply
Here is the console log data from line 170 as you suggested. First time when function calls(First Console.log)
[ 'plugin' ]
Second time when function calls(Second Console.log)
[ '$', 'name', 'js-module', 'description', 'repo', 'issue', 'author', 'license', 'keywords', 'engines', 'hook', 'platform' ]
Here is the third function call which is made from line number 199 form "before_plugin_install.js" with data xmlData[tagName] is name" and function "findPreference" is passed with "cordova-plugin-googlemaps" that causes error at line 169 where xmlData is "cordova-plugin-googlemaps".
Object.keys(xmlData);
The XML parser can't parse the file data of the link I provided because I have added some text to point for everyone to visit that place for the reference I have used in file shared at google docs. (I will add suggestion for others to understand Thank you very much for pointing that out).
EDIT(21-04-2018)
There is some progress with this.
Added plugin again via command line(by navigating to the respective project) using the following command
cordova plugin add cordova-plugin-googlemaps \ --variable API_KEY_FOR_ANDROID="..." \ --variable API_KEY_FOR_IOS="..."
Replaced my keys with "..." respectively
after that started receiving error related to "PLAY_SERVICES_VERSION" so applied the following command
cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=11.8.0
Now currently having following
"Could not get unknown property 'ANDROID_SUPPORT_V4_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler"
I tried solving this issue using following command but the error persists
cordova plugin add cordova-plugin-android-support-v4
it installs cordova-plugin-android-support-v4(21.0.1)