这是我在安装geolocation插件和ngCordova之后得到的错误:
E/AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/www/lib/ngCordova/dist/ng-cordova.js
D/JsMessageQueue: Set native->JS mode to OnlineEventsBridgeMode
E/ConnectivityManager.CallbackHandler: callback not found for RELEASED message
I/chromium: [INFO:CONSOLE(17922)] "Uncaught Error: [$injector:modulerr] Failed to instantiate module restaurant due to:
Error: [$injector:modulerr] Failed to instantiate module ngCordova due to:
Error: [$injector:nomod] Module 'ngCordova' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.3/$injector/nomod?p0=ngCordova
我运行了以下命令:
C:\Users\G\takeaway>ionic plugin add cordova-plugin-geolocation
Fetching plugin "cordova-plugin-geolocation" via npm
Installing "cordova-plugin-geolocation" for android
Fetching plugin "cordova-plugin-compat" via npm
Installing "cordova-plugin-compat" for android
C:\Users\G\takeaway>bower install ngCordova
bower invalid-meta for:C:\Users\G\takeaway\bower.json
bower invalid-meta The "name" is recommended to be lowercase, can contain digits, dots, dashes
bower ionic#1.3.2 cached https://github.com/driftyco/ionic-bower.git#1.3.2
bower ionic#1.3.2 validate 1.3.2 against https://github.com/driftyco/ionic-bower.git#1.3.2
bower ngCordova#* cached https://github.com/driftyco/ng-cordova.git#0.1.27-alpha
bower ngCordova#* validate 0.1.27-alpha against https://github.com/driftyco/ng-cordova.git#*
bower ionic#1.3.2 install ionic#1.3.2
bower skipped ionic was not installed because there is already a non-bower directory with that name in the components directory (www\lib\ionic). You can force installation with --force.
ionic#1.3.2 ..\AppData\Local\bower\cache\packages\75785deacc09255f971c33542b04c50a\1.3.2
├── angular#1.5.3
├── angular-animate#1.5.3
├── angular-sanitize#1.5.3
└── angular-ui-router#0.2.13
C:\Users\G\takeaway>
我按照文档包含该文件。我还在我的代码中包含了该模块:
var app = angular.module('restaurant', ['ionic', 'ngCordova', 'firebase']);
ngCordova文件出现在以下位置:
C:\Users\G\takeaway\www\lib\ngCordova\dist
答案 0 :(得分:1)
我已经解决了这个问题。不得不将ngCordova目录复制到:
C:\Users\G\takeaway\platforms\android\assets\www\lib