Build not creating main.js file

When I try to ionic build android something is causing the main.js file not to be generated so the following error is kicking out when attempting to run it on a local device:

E/AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/www/build/main.js

Your system information:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS:
Node Version: v6.7.0

1 Like

Try
cordova prepare
then
ionic build

I am also having this problem – Ionic Serve works but running on device does not. Fails with Failed to Load Resource main.js.

I tried using both ionic prepare and cordova prepare before hand, no change.

My system information:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS: Windows 7 SP1
Node Version: v6.7.0

Just solved this – was due to TS errors and a leftover .tmp directory that was failing to clean out. Look in the ‘run’ log in the console to track down any compiler errors…

2 Likes

I have the same problem.

Any update about this? Having the same problem.

Same problem in my project, also Ionic 2.0.0 RC 0

Solved in my case. I really had a build error in the console log. ionic serve was working, but not the android build. There seem to be stricter rules! In my case a pipe call was not working, see [SOLVED] Pipes in RC0 . After fixing that, the android build worked again and main.js was created.

where is the “run” log?

Just the output of the console after you run the 'ionic run android’
command…

For me the output has an error saying:

build dev failed: Cannot set property 'fileSystem' of null

Build does not fail when I do:

ionic build android

But it does when I do:

ionic run android -l -p 9999 -r 9998 -c