"Could not find cordova.js script tag. Plugin loading may fail."

I run into this issue seemingly at random. Sometimes the app loads, sometimes it does not.

I’m running Ionic v4-b11 and Cordova Android 7.1.1. I’ve tried putting <script src="cordova.js"></script> into my index.html page, but then the console notes that I already have it installed. So it’s either not installed, or double installed.

Anybody have a solution to this?

In an Ionic v4 app? I think with Ionic v4 you should actually not add manually a reference to cordova.js. At build time the reference should be added automatically I think, at least that’s my conclusion (see https://github.com/ionic-team/ionic/issues/15143#issuecomment-425250132)

In an Ionic v3 app, have you try to move the reference in <head/> or <body/> do that change something?

Yes, this is an Ionic 4 app. I didn’t think I should need to add a reference to cordova.js, but that’s definitely what the console.log is telling me the problem is.

For a bit more detail, my app is loading the main page it should open to, but none of the plugins are working so I can’t retrieve files, show the statusBar, or do anything other than HTML and JS code.

on iOS or Android? if iOS recently upgrade to Xcode 10?

Android. I’m currently testing on a Samsung Galaxy Tab S3 running Android 8.0.0.

Spend my all day testing my app on iOS and Android and didn’t noticed any problem, weird

You already tried to remove/add the platform again?

Yup, did that a few times over actually.

:frowning: damned I’m a bit out of idea right now (long day). You Ionic CLI is up-to-date?

p.s.: I double checked I use 7.1.1 too and cordova 8.1.2 but don’t think that’s the reason

1 Like

I compulsively check for updates, so I know it is.

Hopefully someone else can offer some thoughts on this. I appreciate your input though. =]

1 Like

Final thought, so in src/index.html you didn’t added the reference manually right (which I suppose is the correct way with v4)? so after having build your platform ionic cordova build android do you find any cordova.hash.js references in your ./app/src/main/assets/www/index.html ?

In src/index.html, I’ve tried adding the <script> reference, but the console tells me that Cordova.js is already included. When I remove the <script> reference, the console tells me that Cordova.js is not included.

It seems to be a case of double-or-nothing, and both have the issue of plugins occasionally not loading.

but, sorry for insisting, when you remove the tag do you find a tag which would have been automatically added in ./app/src/main/assets/www/index.html?

if not that’s maybe the problem which you might need to submit to https://github.com/ionic-team/ionic-cli/issues ?

I hope my comments helps a bit, don’t want to disturb

1 Like

@mlynch which version of ng-toolkit are you using? there is an issue which may interest you and seems to be linked with your problem, see https://github.com/ionic-team/ionic/issues/15893

It appears I was using version 1.0.0, so I changed it to the v1.0.8 noted in the link you’ve included. Unfortunately the issue remains.

The strangest thing is that it’s inconsistent. Sometimes it says it can’t find the script tag, sometimes it does find it. I don’t change anything in the way I’m building or running the code - just the same “ionic cordova run android --prod” every time.

My gosh I was really hopeful on that last post :joy: sorry no more idea right now, maybe follow the issue anyway, at some point maybe someone will post something interesting

1 Like

For anyone else with this problem, I’ve worked with Ionic Support and they’ve confirmed that this “Could not find…” error is meaningless, and it won’t actually affect your app. If you’re running into errors and see this warning, it’s a red herring and the problem lies elsewhere.


I have the same issue. It seems like all the cordova plugins load before cordova.js does. I found this out in index.html from google chrome console. Anyone has thought on this?

In my case while running “ionic cordova run android --prod” I saw in index.html

<script type="text/javascript" src="runtime.8e97b949ffa4ba899ee9.js"></script><script type="text/javascript" src="es2015-polyfills.8ae128997d7d9cfd557c.js" nomodule></script><script type="text/javascript" src="polyfills.1c26d1ea37e588a03cf7.js"></script><script type="text/javascript" src="cordova.935a9f4e1f7afeca168d.js"></script><script type="text/javascript" src="main.da0a53cbc0a8dc70a48a.js"></script></body>

The script tags are being added after the app-root … that could explain something

I see the exact same thing:

Honestly I do not feel good just ignoring warnings…

I think I solved the issue by checking the plugin list and adding each one in app.module.js providers. I was missing two plugin intializations there, by adding in app.module.js i solved the issue. May be it might help someone else as well