0

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)

Ashutosh
  • 1
  • 2
  • Try to add a console.log of "keys" in before_plugin_install.js at line 170, i think xmlparser is unable to read something in plugin.xml file. – Frix33 Apr 20 '18 at 06:27
  • @Frix33 i have added the console log from line 170 to the question above at the bottom. Can you please review. – Ashutosh Apr 20 '18 at 06:57
  • Hmm.. i build plugin with **cordova-cli 7.1.0** in VS2015 with no issues.. What cordova version are you using? Because VS15 by default uses 6.x,and in readme of plugin it report **"You need to specify cli-7.1.0 or greater version"** – Frix33 Apr 20 '18 at 07:27
  • Hey @Frix33 thank you for pointing out version compatibility. I used **cordova-cli 6.5.0** that might be the issue but when i try to build with 7.1.0 or 8.0.0 it fails. can you please have a look at the log to this link [error log link at page 12](https://docs.google.com/document/d/1lA9nGsT4KXcXVwVQ4fbh9D2DDBXrY-CVTlt_xBHXoR0/edit?usp=sharing) – Ashutosh Apr 20 '18 at 12:27
  • Yes build with cordova 7.1 in VSCordova is a little tricky. Read my answer in this post: [https://stackoverflow.com/questions/48080658/taco-roadmap-update-11-with-cordova-7-support/49357659#49357659](https://stackoverflow.com/questions/48080658/taco-roadmap-update-11-with-cordova-7-support/49357659#49357659) – Frix33 Apr 20 '18 at 12:31
  • @Frix33 I appreciate you helping with the link. Do i need to go specific with the versions. as i have node 4.7.0 installed and in you link it states 4.8.7 and does it need to 32 bit or 64 bit. – Ashutosh Apr 20 '18 at 12:37
  • Ii have tested only with 4.8.7LTS x64 but i think no significative difference between all node 4.x versions. It does not work with node > 4.x and older for compatibility issues with vs-tac node module and that version. – Frix33 Apr 20 '18 at 12:43
  • It's not working. Still successfully build 6.5.0 projects. – Ashutosh Apr 20 '18 at 13:58

1 Answers1

0

The plugin is installed but still having error while running from visual studio.
So I switched to command line and updated everything.
currently using cordova 8.0.0
gradle 4.7

Still taking care of few task by visual studio.
Please refer below link to see how I worked on it to solve the problem.
Link to GITHUB cordova-googlemaps-plugin issues

Please feel free to post comment if you find yourself in same mess.
Thank you Guys.

NOTE:- For this particular issue cordova-android-play-services-gradle-release plugin is not needed to solve.

Ashutosh
  • 1
  • 2