Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I find cordova.js?

I'm writing a mobile app with HTML5, Javascript and CSS3. I'm using phonegap.

So if I use something like this.

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    document.addEventListener("backbutton", onBackKeyDown, false);
}

function onBackKeyDown() {
    alert("test");
}

I get this error:

cordova : You must have cordova.js included in your projects, to be able to trigger events.

I'm using Ripple to emulate a smartphone. And its right. I don't have cordova.js in my project folder, because I don't know where i get it. I have downloaded the newest version 2.9.0 of phonegap and using specially cordova-mobile-spec.

There is no cordova.js just a cordova-incl.js. How do I obtain this file?

like image 771
Erdem Güngör Avatar asked Jul 15 '13 09:07

Erdem Güngör


People also ask

Where is Cordova JS located?

inside the head of your index. html document. The Phonegap builder will find and include the correct cordova. js file for each build (Android, Win phone, iOS).


4 Answers

I wasted a lot of time looking for a solution on the question "Where get the cordova.js?".
I am developing a mobile app using html+css+jQuery mobile and i am building it using the phonegap web build service. The version of phonegap i am working on is 3.1.0.

I was trying to find how to use the Phonegap API on my mobile application and how to call the cordova methods (ex notification.alert). The solution to this is to just add the

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>  

inside the head of your index.html document. The Phonegap builder will find and include the correct cordova.js file for each build (Android, Win phone, iOS).

Finally, the ondeviceready event is essential to any application. See the Full Example.

like image 193
Georgios Syngouroglou Avatar answered Oct 16 '22 13:10

Georgios Syngouroglou


Check the cordova.js inside the new project created (by using command line)

OR

CHECK YOUR LIB FOLDE INSIDE THE DOWNLOADED CORDOVA ZIP FILE

enter image description here

enter image description here

FOR IOS CHECK cordovalib folder

enter image description here

enter image description here

ANDROID

enter image description here

Please check libs folder of each platform.

like image 44
Arjun T Raj Avatar answered Oct 16 '22 11:10

Arjun T Raj


I also wasted a lot of time trying to figure out what was going on here, because not even George's solution was working for me.

Finally I realized that, as my index.html page is not in the root of the www folder, but inside a subdirectory of it, I should be then setting a relative path for the cordova file (i.e. src="../cordova.js").

Hope it helps anyone else having the same [dumb] issue.

like image 8
Cristiano Dalbem Avatar answered Oct 16 '22 13:10

Cristiano Dalbem


If you are trying to run on your browser for testing, it is suggested to build for browser and run from there, because every time you build the right cordova.js file is included according to the platform.

To build for browser:

cordova build browser

To run:

cordova run browser

More options

cordova run browser -- --port=8001 --target=Firefox

To run with plugins here is a quick intro guide https://www.raymondcamden.com/2016/03/22/the-cordova-browser-platform

like image 2
Netham Avatar answered Oct 16 '22 13:10

Netham