47

Hi I am n00b in classpath and Ant. While reading the tutorial of GCM for Android I came across a line

Step 1: Copy the gcm.jar file into your application classpath

To write your Android application, first copy the gcm.jar file from the SDK's gcm-client/dist directory to your application classpath.

I got the gcm.jar from the dist folder. Now how do I put it into my classpath using Eclipse(I think that would be easier)? And where would I make changes if I didnt have Eclipse?

Thnaks

laalto
  • 150,114
  • 66
  • 286
  • 303
vincent mathew
  • 4,278
  • 3
  • 27
  • 34

5 Answers5

35

Right click on the project in which you want to put jar file. A window will open like this

enter image description here

Click on the AddExternal Jars there you can give the path to that jar file

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
  • 1
    @sai: From the SDK Manager: install Extras > Google Cloud Messaging for Android Library. Note: If you don't see Extras > Google Cloud Messaging for Android Library in the SDK Manager, make sure you are running version 20 or higher. Be sure to restart the SDK Manager after updating it. – Bhavana Vadodariya Nov 29 '12 at 12:36
33

As of rev 17 of the Android Developer Tools, the correct way to add a library jar when.using the tools and Eclipse is to create a directory called libs on the same level as your src and assets directories and then drop the jar in there. Nothing else.required, the tools take care of all the rest for you automatically.

Barak
  • 16,318
  • 9
  • 52
  • 84
6

First copy your jar file and paste into you Android project's libs folder.

Now right click on newly added (Pasted) jar file and select option

Build Path -> Add to build path

Now you added jar file will get displayed under Referenced Libraries. Again right click on it and select option

Build Path -> Configure Build path

A new window will get appeared. Select Java Build Path from left menu panel and then select Order and export Enable check on added jar file.

Now run your project.

More details @ Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)

Sanjay Joshi
  • 2,036
  • 6
  • 33
  • 48
  • Note that [link-only answers are discouraged](http://meta.stackoverflow.com/tags/link-only-answers/info), SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Sep 07 '13 at 06:40
2

Right click your project in eclipse, build path -> add external jars.

LanguagesNamedAfterCofee
  • 5,782
  • 7
  • 45
  • 72
1

In your Android Developer Tools , From the SDK Manager, install Extras > Google Cloud Messaging for Android Library . After the installation is complete restart your SDK.Then navigate to sdk\extras\google\gcm\gcm-client\dist . there will be your gcm.jar file.