PaulWen
PaulWen

Reputation: 1004

AngularJS 2 and Cordova: "Failed to load resource: net::ERR_FILE_NOT_FOUND"

I am trying to get an Angular2 app running natively on Android using Cordova. Unfortunately, the app only shows the loading screen of the Angular app but is not able to load the app.

I am getting the following error message:

Failed to load resource: net::ERR_FILE_NOT_FOUND     file:///app/styles.css 
Failed to load resource: net::ERR_FILE_NOT_FOUND     file:///app/libs-bundle.js
Failed to load resource: net::ERR_FILE_NOT_FOUND     file:///app/main.js Failed to load resource: net::ERR_FILE_NOT_FOUND

It seems like all the local resources included in the app cannot be loaded.

Upvotes: 5

Views: 8525

Answers (2)

Gavin
Gavin

Reputation: 487

<base href="./" /> or <base href="." /> also works, the same approach. Thanks for your commit, it helped me.

Upvotes: 7

PaulWen
PaulWen

Reputation: 1004

I finally found the problem:

For the routing inside the Angular2 app I defined the <base href="/"> tag in the index.html. This works fine when running the app from a web-server. Though, for Cordova/Phonegap it has to be changed to <base href="file:///android_asset/www/" />.

Upvotes: 11

Related Questions