Unknown provider: $cordovaProvider

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?

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.

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!

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

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): AngularJS

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.

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.

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): AngularJS

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?

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

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.

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?

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,

5 Likes

@jcarballo Thank you!

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