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


#1

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?


#2

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?


#3

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.


#4

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


#5

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


#6

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?


#7

Yup, did that a few times over actually.


#8

: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


#9

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

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


#10

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 ?


#11

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.


#12

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


#13

@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


#14

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.


#15

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


#16

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.


#17

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?