“android_asset/www/” missing from file paths when

2019-02-24 18:39发布

问题:

I'm working on an ionic app (ionic v1.7.13, cordova v5.4.1). When I run

ionic run android -l

everything works fine, all my project files are properly loaded. The problem arises when I try to run without livereload, specifically because livereload causes issues when accessing device files.

ionic run android

When I run this command I see only the html file rendered, and in the dev tools I see

Failed to load resource: net::ERR_FILE_NOT_FOUND file:///lib/ionic/css/ionic.css
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///css/style.css
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///lib/ionic/js/ionic.bundle.js
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///lib/ionic/js/angular/angular-resource.js
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///lib/ngCordova/dist/ng-cordova.js
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///cordova.js
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///js/app.js
...

I can go through and add "android_asset/www/" to those routes and it works... but I think I must be missing something.

I'm looking for any guidance in others who have had this issue. Thanks!

回答1:

turns out that trying to include html5location's in angular that it breaks the routes.

by removing <base href="/"> from my index.html file I fixed all the relative routes and my problem.

Cheers!



回答2:

Add this to config.xml

<access origin="*"/>
<access origin="tel:*" launch-external="yes"/>
<allow-navigation href="*"/>
<allow-navigation href="http://*/*"/>
<allow-navigation href="https://*/*"/>
<allow-navigation href="data:*"/>
<allow-intent href="*"/>
<access origin="*"/>