Can't find cordova.jar file in phonegap? - android

I am new to phonegap the tutorials I have referred to says that there should be a cordova.jar file inside the phonegap-2.9.1\lib\android path. But I don't have it in this phonegap 2.9.1 version.
Can I download the cordova.jar from anywhere or is there any alternative?
Someone please help me.
Thanks.

First, you need the following requisites, for sure are covered if you have been playing with phonegap/cordova for a while ;)
Java JDK 1.5 or greater
Apache ANT 1.8.0 or greater
Android SDK http://developer.android.com
And then, to generate the cordova-2.9.1.jar file, follow the next steps:
Download and extract the phonegap-2.9.1.zip file.
In a terminal/cmd window go inside the recently extracted directory:
$ cd phonegap-2.9.1\lib\android\framework\
Execute the following commands (you need android sdk and ant already configured in your system path):
$ android update project -p . -t android-17
If required add the --subprojects parameter:
$ android update project -p . -t android-17 --subprojects
You get a message like this:
Updated project.properties
Updated local.properties
build.xml: Found version-tag: custom. File will not be updated.
Updated file D:\work_NEW\phonegap-2.9.1\lib\android\framework\proguard-project.txt
Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using Activity name 'DroidGap'.
If you wish to change it, edit the first line of build.xml.
Added file D:\work_NEW\phonegap-2.9.1\lib\android\framework\bin\build.xml
Added file D:\work_NEW\phonegap-2.9.1\lib\android\framework\bin\proguard-project.txt
Finally run:
$ ant jar
Blablabla....
jar:
[jar] Building jar: xxx\phonegap-2.9.1\lib\android\framework\ cordova-2.9.1.jar
BUILD SUCCESSFUL
Total time: 4 seconds
Done!!!!! The file is ready! And you can find this and other information reading a file inside the phonegap-2.9.1.zip:
phonegap-2.9.1\lib\android\README.md

Since 3.x version phonegap has changed a lot. I suggest you to install 3.3 version and create a proyect following the steps described in the offical page.
Also, you can download cordova from cordova web page, add to path, and create a proyect using terminal:
cordova create app_name
cordova platform add android || cordova build android

In 3.3.0 version, You can get cordova-3.3.0.jar file by following these steps:
Go to Command Prompt:
$ cd %HOMEPATH%/.cordova/lib/android/cordova/3.3.0/framework
$ android update project -p
$ ant jar
After executing these commands you will get cordova-3.3.0.jar in framework folder i.e.
=> %HOMEPATH%/.cordova/lib/android/cordova/3.3.0/framework/cordova-3.3.0.jar

Related

Cordova 3.3.x - Android CordovaLib

When was the cordova.jar file removed from Cordova and replaced with CordovaLib? I was previously running Cordova 3.1.0-0.1.0.
Today I have upgraded to Cordova 3.3.0 (which was quite a headache, but I've completed the upgrade) and I've noticed a difference in my Android project structure: Cordova has created my project (with what I've named it) and it has also created -CordovaLibs.
Is this right? I know iOS it does this - but not Android (as I say, usually a JAR is added).
It's introduced in 3.3, had me baffled too.
Cordova 3.3 release notes:
http://cordova.apache.org/announcements/2013/12/16/cordova-330.html
CB-5232 Change create script to use Cordova as a Library Project
instead of a .jar
To generate file cordova3.3.0.jar, just follow these steps bellow:
Open your cmd, and go to the root folder where Cordova is installed:
$ cd ~/.cordova/lib/android/cordova/3.3.0/framework
Run the following command, notice the trailing dot
$ android update project -p .
Use ant to generate file jar. Be sure you have configure PATH for
$ ant jar
Now, you can copy file cordova3.3.0.jar to libs directory and import to your project. Hope it's helpful

How do I update an Android project from a Jenkins job?

I am setting up Jenkins to clone my git project, update the project, then build using ant. If I perform an ls in the job after cloning the repo, I see my project.properties file present (containing target).
To update the project (and therefore generate the build.xml file) I issue the following command:
android update project -p ./
However, I get the following console output:
Error: The project either has no target set or the target is invalid.
Does anyone know how to update an android project from Jenkins and avoid this problem?
So you've eliminated the first part of the error (i.e. the project does have a target set), but not the second part.
The message "target is invalid" means that you don't have the target platform installed in the Android SDK that Jenkins is using.
e.g. if your target is android-17, then you need to install the Android 4.2 platform (for example via the command android update sdk -u -t android-17).
As an aside, you can automate both the relevant calls to android update -p and the installation of required target platforms using the Android Emulator Plugin for Jenkins.

cordova-android ./create $( which android ) exited with a 1

After executing the command to create a project...
./create <PATH_TO_PROJECT_DIR> <COM_PATH> <PROJECT_NAME>
I get the error message:
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
Troubleshooting responses:
(acconrad provided a smart checklist here for solving Cordova errors...)
Did you download the correct version of PhoneGap from the correct LOCATION? It appears as if
there are versions of PhoneGap that do not come packaged with
Cordova-2.x.0.jar, which is necessary to run the script. Download here
to obtain PhoneGap with the correct JAR file.
I have followed the instructions at the official Apache Cordova API Documentation site and downloaded the cordova-android repository from github. The official documentation does not say anything about this jar file and as such I have not executed it.
Did you already create the folder? The documentation claims that you
can use this command as long as the new folder is blank. This is not
true. Make sure the folder does not exist before attempting to create
the project.
Fresh folder path, never created.
Do you have the latest version of Ant? You will need Ant 1.8.0 or
greater to run PhoneGap with Android. Use ant -v to verify your
version.
Ant version 1.8.2, although running the -v flag pops up the following output...
Apache Ant(TM) version 1.8.2 compiled on June 3 2011
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed
...as if it was trying to build. I assume -v means verbose and ant is trying to build the current director, in which there is no build.xml file, because I'm not building a project with ant, merely finding the version, which is 1.8.2.
Is your .bash_profile/Environment Varibles PATH set properly? The
official documentation has been updated to reflect this, but you will
absolutely need these variables set correctly in order to create the
project.
Both SDK paths have been set & sourced.
Did you update the terminal to reflect your new PATHs? source
.bash_profile or . .bash_profile in your currently open terminal
window so your paths are updated when running the create command.
Haven't restarted but $PATH outputs the correct android-sdk-macosx paths (platform-tools && tools).
Do you have the correct commons-codec? You may receive an accompanying
error referring to a missing commons-codec file, which you can
download here.
No commons-codec accompanying error is being displayed.
The problem was indeed the PATH variables...
/PATH/TO/android-sdk-maxosx/platform-tools
/PATH/TO/android-sdk-maxosx/tools
removed the macosx from the path name.
Correcting these environment variables in ~/.bash_profile solved this problem.
You should modifying the PATH Environment Variable:
For Ubuntu:
$ nano ~/.bashrc
You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following:
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
https://help.ubuntu.com/community/AndroidSDK
For Mac OS:
look in your home directory for .bash_profile. Create the .bash_profile file if you don't have one.
Look for the PATH environment variable and add the full path to the tools/ directory to the PATH. If you don't see a line setting the PATH, you can add one: export PATH=${PATH}:/tools
https://sites.google.com/site/richgossweiler/home/android-development-notes/installing-the-android-sdk-on-the-mac-os-x
This also happens if the name of the COM_PATH contains an invalid character or does not have 3 namespaces like:
com.example.project
This is probably because of a wrong PATH. You should edit environment variables in ~/.bash_profile.
Refer this Blog post for a detailed explanation.

Cannot update the project in android ndk

I'm using linux and i have successfully installed ndk and configured it. with the help of Android NDK installation But i can't able to generate build.xml file
root#ndot-173:~/Desktop/NDK4/samples/bitmap-plasma# android update project -p . -s
android: command not found
It shows command not found.
How do i generate build.xml file..?
you have to add android sdk in you PATH or
you use the absolute path of the android command ex: you_android_sdk_path/tools/android

ant build error after exporting with eclipse

I exported my project to build.xml in order to use ant.
When I execute 'ant debug' from the command line it outputs Target "debug" does not exist in the project.
What to do?
If you are trying to build with the auto generated ant scripts from android. You need to do an android update project on the project in question and then use the build.xml file that is generated from that.
To do this:
Go to the project in question with a terminal or command prompt.
Then type the following command android update project -p . This will update the current project that you are inside.
The command above also assumes you have the android.bat location on your path. If you do not, you need to use the entire path to your android.bat location. Which should be similar to android-sdk/tools/android.bat.

Categories

Resources