Closed jamorton closed 10 years ago
Oh, interesting.
A few questions to help me recreate the issue:
I was using phonegap run ios
. I'm not using any plugins at the moment. I got the error in the safari developer console.
Thanks @Jonanin
When I have a moment, I'll look into the issue.
As a workaround, you can actually script include cordova.js
. There are no side-effects to doing this. The phonegap.js
is mostly around for legacy support.
So I can include cordova.js
instead of phonegap.js
? I was using the latter simply because it's what the demo project (phonegap create
) uses. Good to know, though. Thanks.
Yep, the two are identical and phonegap
should support both.
Just noting that I ran into this today as well. It seems to be the first gotcha a new developer will see when trying to do a hello world with any plugins.
Switching to cordova.js doesn't seem to have helped (or hurt). Manually adding a script tag for my plugin's JavaScript asset is the workaround I'm using now, but I gather that approach is not recommended...
@jchris
Interesting and uncool (on our part).
This is the culprit with respect to using phonegap.js.
Can you give a little more detail on how it is failing with cordova.js
?
Thanks!
This is with iOS and the Couchbase Lite plugin at https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin
Adding litegap.js to my html works fine, it just seems the plugin loader isn't adding automatically.
@jchris
Ahhh... okay, so only JS Modules are injected at runtime by the cordova.js
... not assets.
Try removing your <script src="litegap.js">
from your HTML file.
Update your litegap.js
from:
window.litegap = {
to:
module.exports= {
And update your plugin.xml
from:
<asset src="www/litegap.js" target="litegap.js"/>
to:
<js-module src="www/litegap.js" name="litegap">
<clobbers target="window.litegap" />
</js-module>
You can read more about the plugin spec on our docs site.
Props to @filmaj for reviewing the above details.
Thanks for the pointer. Somehow I didn't notice the "js-module" stuff in the plugin spec earlier. I'm updating the plugin this week anyway so I'll make that change before I push it to the plugins repo.
No worries. It's a lot of wrap your head around.
When you have a chance to give it a try, can you update this issue on whether it helped?
If I have a moment, I should just send you a pull request... in retrospec, it would have been quicker than writing out the steps above :S
I think I'll be changing enough things that the pull request wouldn't merge clean anyway. We are renaming from "LiteGap" to something less pithy, along with a few other changes.
On Tue, Aug 6, 2013 at 4:10 PM, Michael Brooks notifications@github.comwrote:
No worries. It's a lot of wrap your head around.
When you have a chance to give it a try, can you update this issue on whether it helped?
If I have a moment, I should just send you a pull request... in retrospec, it would have been quicker than writing out the steps above :S
— Reply to this email directly or view it on GitHubhttps://github.com/phonegap/phonegap-cli/issues/134#issuecomment-22218813 .
Chris Anderson http://jchrisa.net http://www.couchbase.com
Hello, I got the same problem and I can't resolve it. I work with phonegap 2 days. Android is target platform for me in this time. Help me please!
P.S. If I use FileTransfer, I got message: java.lang.ClassNotFoundException: org.apache.cordova.FileTransfer. Best regards
I'm running into this issue with phonegap's contactManager plugin. No matter what I do navigator.contacts === undefined.
I can see after running phonegap build android that the android config.XML contains
<feature name="Contacts">
<param name="android-package" value="org.apache.cordova.ContactManager" />
</feature>
and the manifest includes
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
also, my phonegap main config.xml file contains
<feature name="http://api.phonegap.com/1.0/contacts" />
<gap:plugin name="ConactManager" />
And, I also ran phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts.git
as mentioned here: http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface, and it installed properly.
But again, contacts.navigator is always undefined, and logcat is showing the "could not find cordova.js script tag. Plugin loading may fail". I have broken my app down to have absolutely no javascript except for phonegap.js (i've tried cordova.js also as mentioned in the comments above), and an event listener for 'deviceready', which does fire, but again, and finally, contacts.navigator is always undefined.
I feel my issue is completely related to the above.. Can you please point me in the right direction? No documentation seems to mention the exact, full, setup process for adding plugins that phonegap provides.
Thanks!
same here. To reproduce it just create a new project, add the Audio plugin and run it.
08-20 23:07:30.089: I/Web Console(584): Could not find cordova.js script tag. Plugin loading may fail. at file:///android_asset/www/phonegap.js:1836
im also getting the same issue
phonegap -v 3.0.0-0.14.3
I have also the same issue, tryed to include cordova.js directly, but it didn't work. The phonegap version is 3.0.0-0.14.3 and i build the app for android only. The included plugins are network-information and globalization. Hope that you can fix this bug soon.
same problem here. but it worked last week... I think i just reinstalled the phonegap last week, but i don't remember when.
Problem solved. i have an error in my js file.....
But i do get warning: I/Web Console(26330): Could not find cordova.js script tag. Plugin loading may fail. at file:///android_asset/www/phonegap.js:1836, but which did not stop my app to run normally (the plugin works)
I had same problem here and i try to check cordova.js file and phonegap.js. I found the me "console.log('Could not find cordova.js script tag. Plugin loading may fail.')" at line 1836.
A function "findCordovaPath" tries to find in html file an to in my index.html. As mentioned by mwbrooks the files are identical so it shouldn't have any effect.
Another reference to this issue http://stackoverflow.com/questions/20076433/phonegap-cordova-js-is-missing
Thx @jchris for linking my question. I hope i will find answer soon because i am loosing my mind.
+1 to referencing cordova.js instead of phonegap.js for removing this error.
I Am using phonegap 3.3.0 and still having this problem. I installed the latest phonegap an cordova 2 days ago, and still struggling with my upgrade from phonegap 2.9.0 to phonegap 3.3.0 (3.3.0-0.18.0). Got the same issue:
01-05 09:04:16.557: D/CordovaLog(698): file:///android_asset/www/phonegap.js: Line 1544 : Could not find cordova.js script tag. Plugin loading may fail. 01-05 09:04:16.567: I/Web Console(698): Could not find cordova.js script tag. Plugin loading may fail. at file:///android_asset/www/phonegap.js:1544
Weird... after 2 days of errors and trying a lot of things... (see: http://stackoverflow.com/questions/20923738/upgrade-to-phonegap-3-3-0 ) I removed all plugins and reinstalled them..... and now it works.... I never thought upgrading should take this long... I hope the upgrading framwork in phonegap 3.x does what it promishes.... Is there a way to improve documentation about the errors somebody could encounter..... ?
As someone who just started with Phonegap, this makes you guys look bad. And it seems like a 1 line fix. Fix it.
Renaming from phonegap.js to cordova.js works also for me. Weird that such a simple fix it's not yet solved after 8 months.
This issue was caused by a particular build of phonegap.js, and while it's caused some frustration, does not seem to affect all users. Could not replicate, so closing.
Well that is very interesting indeed. I just went through the interesting experience of learning how to turn on logcat before I found that my standard "Hello World" app on android was looking for a file called phonegap.js. After I figured out that I only have cordova.js, I made the connection. It is not cool to have a hello world that does not give the gratification of switching button color and saying "DEVICE IS READY" Lets fix this. What can I do to help?
Yea, its funny they closed this bug and people are still having the same issues over and over. Can't believe it still out there.... Sad.
On Wed, Apr 9, 2014 at 11:24 AM, Thomas notifications@github.com wrote:
Well that is very interesting indeed. I just went through the interesting experience of learning how to turn on logcat before I found that my standard "Hello World" app on android was looking for a file called phonegap.js. After I figured out that I only have cordova.js, I made the connection. It is not cool to have a hello world that does not give the gratification of switching button color and saying "DEVICE IS READY" Lets fix this. What can I do to help?
Reply to this email directly or view it on GitHubhttps://github.com/phonegap/phonegap-cli/issues/134#issuecomment-39999019 .
Stephen Pope Partner / Developer Project Ricochet
www.projectricochet.com
(909) 276-7055
@popestepheng the bug was closed as CNR: could not replicate. Post your steps to replicate and I will reopen.
@thovel Thanks! If you feel up to the challenge of fixing this yourself, simply write/document/test a fix and send a pull request, referencing this issue and I'll pull it in.
If you want some help with the above (or want me to do it) first step is to post your EXACT steps to replicate, including information like dev environment (W7/W8/OSX/NIX/etc), mobile environment (OSX,WP8,DROID/etc) and any code or modifications to helloworld.
A note on phonegap.js: this exists for backwards compatibility only, internally cordova.js is used.
For all the folks frustrated by this: I reinstall the cli, and run hello world and mobile-spec from Windows/OSX on multiple platforms (android/ios/wp8) multiple times per day. I'm here to help, and I am sorry an irritating issue like this has persisted, but I can't do anything about it unless I can replicate the issue.
--edit-- markup
Have this problem months later, using Ubuntu.
HELLO,
Ok, I'm so frustrated definitelly
My project use the following plugins:
[phonegap] com.chariotsolutions.nfc.plugin [phonegap] com.phonegap.plugins.sqlite [phonegap] org.apache.cordova.dialogs [phonegap] org.apache.cordova.geolocation [phonegap] org.apache.cordova.vibration
When I run my project in debug mode always I see:
[phonegap] successfully installed onto device I/Web Console(22320): Could not find cordova.js script tag. Plugin loading may fail.:1548 I/Web Console(22320): DEBUG: -------------------------------:3521 I/Web Console(22320): DEBUG: Ember : 1.5.1:3521 I/Web Console(22320): DEBUG: Handlebars : 1.1.2:3521 I/Web Console(22320): DEBUG: jQuery : 1.11.0:3521 I/Web Console(22320): DEBUG: -------------------------------:3521
For me is good,because it's works, until I decide to SIGNED my app,
Then I try to change phonegap.js
to cordova.js
and definitelly NOT WORKS,
Allways I see an alert that say me:
There was a problem class not found
and when I accept the alert, in the console I get the following error:
Failed to initialize the NfcPlugin Class not found
I wondering if somone wants to fix it, because I don't know how?, please there are some kind solution?
I don't want change all my project from phonegap to cordova (and find more problems..)
Thanks for answer me Mr @mwbrooks
I haven't read the whole thread 1000%, but I do hope everyone has discovered that cordova.js and/or phonegap.js are added when the app is created.
Therefore, if you test on a browser, the .js files will therefore be missing because they are dependent upon the mobile platform, hence why they are set when you create the app for ios, android etc etc.
Hi, i've got the same error:
phonegap.js:1917 Could not find cordova.js script tag. Plugin loading may fail. file:///android_asset/www/phonegap.js:1917
JS File giving the notice:
var pathPrefix = findCordovaPath();
if (pathPrefix === null) {
console.log('Could not find cordova.js script tag. Plugin loading may fail.');
pathPrefix = '';
}
Hope this could help you debugging.
Could not find cordova.js script tag. Plugin loading may fail.
I get this javascript error from phonegap.js. I think it's because phonegap.js is just a renamed cordova.js, so it's not looking for the right script tag.