Unknown provider: $cordovaProvider


#1

While updating to the latest nightlybuild (805), when launching my app on desktop (browser), I got this:

Error: [$injector:unpr] Unknown provider: $cordovaProvider
http://errors.angularjs.org/1.3.4/$injector/unpr?p0=%24cordovaProvider
    at http://localhost:8100/lib/ionic/js/ionic.bundle.js:7300:12
    at http://localhost:8100/lib/ionic/js/ionic.bundle.js:11187:19
    at getService (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11334:39)
    at Object.invoke (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11366:13)
    at runInvokeQueue (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11281:35)
    at http://localhost:8100/lib/ionic/js/ionic.bundle.js:11290:11
    at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:7559:20)
    at loadModules (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11271:5)
    at createInjector (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11197:11)
    at doBootstrap (http://localhost:8100/lib/ionic/js/ionic.bundle.js:8671:20)

How to fix it? Is it a bug in this nightly build?


#2

Ok, it was ngCordova that changed its api a few days ago.
For those who experienced the same issue with a bower update, this may help.


#3

Hi

I’m suffering terrible from the same issue. Please will you (or someone) tell exactly what the fix is? What do we have import instead of $cordova or $cordovaProvider? Thanks!


#4

Hi,

You will notice if you inspect the github of ngCordova that some files relating to Facebook connection feature has changed.

Check if $cordovaProvider changed to $cordovaFacebookProvider.
Check the history of the commits :wink:

Hope that helps.

Michael


#5

Hi Michael.

Thanks a lot for your repply. But if change it to: $cordovaFacebookProvider, then I get this error:

D/CordovaLog(26180): file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 17696 : Error: [$injector:unpr] Unknown provider: $cordovaFacebookProviderProvider <- $cordovaFacebookProvider

Actually, what I trying to do is to get this recipe to work (as I need to access some other native Android code from Ionic, but I think that It’s better to start with something simple):

http://cordova.apache.org/docs/en/3.0.0/guide_hybrid_plugins_index.md.html#Plugin%20Development%20Guide

I need the access in my controller, so I do this:

.controller('TestCtrl', function($scope, $ionicViewService, $location, $rootScope, $cordova) 

And in my controller I try to call the echo function like this:

cordova.exec(dataFromEchoOK, dataFromEchoError, "Echo", "echo", ["This is a test"]);

Ofcourse dataFromEchoOK and dataFromEchoError are two callback functions also placed in controller.

But then I get this logcat error:

D/CordovaLog(24662): file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 17696 : Error: [$injector:unpr] Unknown provider: $cordovaProvider <- $cordova
D/CordovaLog(24662): http://errors.angularjs.org/1.2.25/$injector/unpr?p0=%24cordovaProvider%20<-%20%24cordova

I really hope that you (or someone else) will tell me how to do this as I really need to get it working as soon as possible. Thanks.


#6

If you looked at the github as suggested, you would notice that you have to replace $cordova by $cordovaFacebook:

.controller('TestCtrl', function($scope, $ionicViewService, $location, $rootScope, $cordovaFacebook)

It was renamed.


#7

Thanks. But then I just get this error:

D/CordovaLog(27937): file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 17696 : Error: [$injector:unpr] Unknown provider: $cordovaFacebookProvider <- $cordovaFacebook
D/CordovaLog(27937): http://errors.angularjs.org/1.2.25/$injector/unpr?p0=%24cordovaFacebookProvider%20<-%20%24cordovaFacebook


#8

Hi Michael (also if others know about this then please answer)

Are you sure that it’s only possible if I use the $cordovaFacebook plugin. I can’t see that my app has anything to do with Facebook, as I only need to access my own Android code?


#9

i don’t figure out exactly what you really want…
Make sure that you have the latest version of ngCordova (with bower update)


#10

Hi Michael

Thanks for your reply. I’ve found that to solve my problem I’ll build my app in another way, and then when I have time for it then I will learn all I need about Cordova plugins! So just forget about it.


#11

What may help? I updated my ionic and bower few days back and everything has got fucked up! Really frustrating when everything was working fine and now I’ve no idea about the root cause of issues as a lot of things stopped working! Please help?


#12

I had a similar problem, I updated and then suddenly I was getting the “Unknown provider: $cordovaOauthProvider <- $cordovaOauth”.

It turns out that in ngCordova now provides ngCordovaOauth separately. In the “lib/ngCordova/README.md” file it reads: - Oauth (available separately)

So, first installed ng-cordova-oauth

$ bower install ng-cordova-oauth -S

Then, I included the file in my app’s index.html

<script src="lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js"></script>

Finally included the module in my app.js

angular.module('myapp', [
  'ionic',
   ...
  'ngCordova',
  'ngCordovaOauth',
   ...
])

That got the app back up and running.

Don’t know yet what further changes in my own auth controller are needed.

Hope it helps,


#13

@jcarballo Thank you!


#14

i am not able to login with instagram. can you plss help me