ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 656 forks source link

Blank Project ERR_FILE_NOT_FOUND #4421

Open Lindsor opened 4 years ago

Lindsor commented 4 years ago

Description: When creating a blank cordova project with the latest Ionic cli (6.7.0) and running it on android the app doesn't load.

Steps to Reproduce:

ionic start project-name blank --cordova --type=angular
ionic cordova platform add android
ionic cordova build android

Then check the chrome console and see:

Failed to load resource: net::ERR_FILE_NOT_FOUND /polyfills-es2015.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND /styles-es2015.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND cordova.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND /vendor-es2015.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND /main-es2015.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND /assets/icon/favicon.png:1

My ionic info:

Ionic:

   Ionic CLI                     : 6.7.0 (/Users/mluz/.npm/_npx/67980/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.1.0
   @angular-devkit/build-angular : 0.803.26
   @angular-devkit/schematics    : 8.3.26
   @angular/cli                  : 8.3.26
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 7.0.1
   Cordova Platforms : android 6.2.3
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 4 other plugins)

Utility:

   cordova-res : 0.14.0
   native-run  : 1.0.0

System:

   Android SDK Tools : 26.1.1 (/Users/mluz/Library/Android/sdk)
   ios-deploy        : 1.9.1
   ios-sim           : 6.0.0
   NodeJS            : v14.0.0 (/Users/mluz/.nvm/versions/node/v14.0.0/bin/node)
   npm               : 6.14.4
   OS                : macOS Mojave
   Xcode             : Xcode 11.3.1 Build version 11C504
imhoffd commented 4 years ago

I'm not able to reproduce this. How are you running the app once it's built?

Lindsor commented 4 years ago

Im doing the same thing i do for my other ionic projects:

npx ionic cordova build android this puts apk in platform/android/.../app-debug.apk then doing: adb install -d -r /<path-to-apk>

imhoffd commented 4 years ago

What's the URL that it loads in the web view? Mine is http://localhost/home.

Lindsor commented 4 years ago

@dwieeb dont kill me here. I tested 5 projects yesterday and all failed. Just did one more today to get you more details and it worked now.

I will keep an eye out and see if it comes back but i think you can close this one.

imhoffd commented 4 years ago

Haha, no worries! I've definitely seen this issue reported before. It happens when there's an inconsistency with the <base href="/" /> and whatever is serving the app. It won't work on file:// protocol (i.e. you can't just open the index.html in your browser and expect it to work). It needs HTML5 routing capability, which the web view in our Cordova plugin should support.

Maybe you were testing it on a really old Android device? I'm out of ideas.

Lindsor commented 4 years ago

Galaxy S20... if thats already considered old were screwed haha. It most likely has to do with some sort of version issue with either cordova or one of the dependencies.

imhoffd commented 4 years ago

Yeah, it should work on an S20 😂

EbenOladutemu commented 4 years ago

This issue hasn't been solved. I ran into the same exact issue. Any solutions?

NabeelHaris commented 3 years ago

This issue hasn't been solved. I ran into the same exact issue. Any solutions?

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