For some reason, after going through Phonegap\'s non-inclusive instructions (it doesn\'t even mention setting up ANT, or the headaches with Ant and JDK), this doesn\'t work
Run cordova -d build
. If it says anything about "Unable to locate tools.jar", fix that. Then completely rebuild the application by running cordova platform rm android
. Also remove the project from eclispe. Then recreate the app by running cordova platform add android
+ cordova build
. Finally add the project in eclipse again.
org.apache.cordova
should now be included and everything should be working.
Download apache cordova jar and add it to lib folder and classpath.
I just ran into the same problem. Following what was written in here, I finally made it work.
After you download cordova from phonegap github page, you will find cordova-2.2.0.jar and cordova-2.2.0.js in lib/android folder. After running "./create ...", copy cordova-2.2.0.jar into your projects libs folder and cordova-2.2.0.js into your www folder. Then import the project into eclipse and it should work.
I had to go to "Project -> Properties -> Android" and select a newer SDK (I selected the latest one available on the list) and than run the "Project -> Clean" as well.
In addition to copying cordova-2.2.0.jar from the phonegapp download to the libs folder of the project I had to manually add it to the projects libraries.
Procedure: Project -> properties -> Java Build Path -> Libraries -> Add JARs... Then select the libs from the project itself
I initially got around this using one of the solutions posted above: about downloading the phonegap from github and pasting in the cordova-2.2.0.jar and cordova-2.2.0.js files into the generated directories.
After fiddling around with the path and environment variables these files are already in place (project/libs/cordova-2.2.0.jar and project/assets/www/cordova-2.2.0.js) now for me after running the "create" command on command line.
I am using the ANT that came bundled with Eclipse so my PATH variable includes:
C:\Program Files\Eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\bin;
and I added an environment variable for ANT_HOME of: C:\Program Files\Eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730
I tested adding \bin or removing it to both the PATH and environment variable for ANT_HOME and this was the winning combination.
Step 4 in the getting started guide is the only part specific to phonegap. The rest is setting up a general android development environment. Instead of eclipse classic, get the ADT bundle from http://developer.android.com/sdk/index.html - that includes a custom version of eclipse with most of the android stuff ready to go.
The default link to cordova-2.2.0.jar worked fine for me, though it did take a bit of effort to work out that if you want to use a custom build of cordova it needs to be set up as an android library dependency in project properties.