Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Ionic at cca throw "Cannot read property 'Keyboard' of undefined" @ app.js:14

The following is what I did to setup Ionic in Chrome App for Mobile:

  1. Created a Chrome App for Mobile project - cca create projectname
  2. Created an Ionic project ionic start projectname_ionic
  3. Deleted all of the files from the Chrome App www folder except the manifest files and background.js - find projectname/www/* -not -name 'manifest*' | grep -v 'background.js' | xargs rm -rf
  4. Copied the content of the Ionic project www folder to the Chrome App www folder - cp -r projectname_ionic/www/* projectname/www/
  5. Commented out <script src="cordova.js"></script> at projectname/www/index.html since cca automatically inject it already

When trying to run the project I get the following error from app.js line 14 -

Uncaught TypeError: Cannot read property 'Keyboard' of undefined

When typing at the console of Chrome dev tools (remote debugging) window.cordova I do get an existing object, so the problem is that window.cordova.plugins is undefined.

btw the app itself does load up at the mobile and I can switch tabs, but at the Friends tab when I click on a name I do see that it got clicked but nothing happen beside that.

I also tried the following:

  1. projectname_ionic/plugins had 3 plugins which projectname/plugins missed so I added them using cca plugin add ... to projectname/
  2. Run ionic platform add android at projectname_ionic/ before copying the files
  3. Tried few older versions of Ionic (desperate I know :))
  4. And some other tries which I forgot already...

Anyone got an idea what should I do?

Thanks in advance!

like image 423
Nimrod Yonatan Ben-Nes Avatar asked Nov 15 '14 18:11

Nimrod Yonatan Ben-Nes


2 Answers

I started getting the same error after removing plugins directory (I had a hook that was adding the plugins as part of the add platform). There are 3 plugins that ionic adds for a new project. I did not have keyboard and console ones as part of my hook.

Check that you have following cordova plugins:

cordova plugin add ionic-plugin-keyboard
cordova plugin add org.apache.cordova.console
cordova plugin add org.apache.cordova.device

Once I added missing plugins to the ones added by hook the error was gone.

Also, if node_modules was removed, npm install will be needed.

like image 169
Irena Shai Avatar answered Oct 03 '22 10:10

Irena Shai


When I tried to add the plugin on Mac OSX the plugin had a different name. You have to run this command in the project directory.

cordova plugin add ionic-plugin-keyboard

You can see the lib here: keyboard plugin

like image 28
anataliocs Avatar answered Oct 03 '22 10:10

anataliocs