Application Error: index.html not found in android asset

I am getting Application Error
The connection to the server was unsuccessful .(file :///android_asset/www/index.html)
while loading the app in emulator.
Working with all the latest version of npm,ionic,cordova. please help.

Please post your ionic info output.

@ionic/cli-plugin-cordova       : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.1.2
Ionic Framework    : ionic-angular 3.6.0


Node : v8.3.0
OS   : Windows 7
npm  : 5.0.4

That looks recent enough.

Can you start a new project with ionic start blank blank and see if you get the same error when you try running it on a device?

i am getting same error message even after starting with fresh blank app.

Note:- i have tried the same in two different laptops and different environment just to make sure its not environment issue.
In one environment ,directly i am getting the error message and app also doesnt load in other environment sometimes apps get loaded and sometime the same error message comes and often the changes will not be reflected in the new build.

Thanks in advance.

Does index.html actually exist in \platforms\android\assets\www?
Can you connect a real Android device and see if ionic cordova run android works?

It does not exist but i think the “cordova run android” will add index.html at run time to the assets/www.
upon running android-debug.apk in the mobile device it works fine as expected.

You should not use cordova commands directly when working with Ionic.

How exactly are you trying to emulate it on your emulator? What commands are you running?

"cordova build android"
then “cordova run android” to run it in emulator.

Use ionic cordova emulate android please. This is the correct command when developing with Ionic.

(Using cordova commands directly omits the “build” step of Ionic which makes for a missing index.html file for example)

Hi sujan i am still getting the same error message. i will try with same command in other scenarios and with different environment will let you know

So it works with ionic cordova run android (which builds the app and runs it on a connected device) but not with ionic cordova emulate android, correct?

emulate command i have not tried but with “ionic cordova run android” i am getting the same error.

Ok, I was making wrong assumptions.

It works on real devices, but not on emulators, correct?
Do you run these Emulators via Android Studio?
Have you tried a Genymotion Emulator?
Can you run other apps on the Emulator?

I have installed emulator through android studio.and it works on real devices but not in emulator.
I will definitely try Genymotion Emulator.

hi sujan,
i am trying to build with ionic cordova build android but i am getting the following error:

[ERROR] An error occurred while running subprocess cordova.