21

I have following problem: I try to use SupportMapFragment from com.google.android.gms.maps.SupportMapFragment which is part of Google Maps Android API v2.

My first approach was to add project to Eclipse from android-sdk\extras\google\google_play_services\libproject\google-play-services_lib location and set it as referenced project in Properties -> Project References menu of MyApp. I also added project to Java Build Path / Projects. Error indicators disappeared from Eclipse but when I tried to run my app I got NoClassDefFoundError exception.

So my second approach was to copy jar file from google-play-services_lib/libs to my project's libs directory. MyApp succesfully started but in LogCat I can see dead code ... something message so I guess that jar file has to be referenced in another way.

And now I am confused and tired..
Maybe someone more experienced in Android can tell me what should I do ?

MichK
  • 3,202
  • 3
  • 29
  • 33

4 Answers4

14

The quick start guide that keyboardsurfer references will work if you need to get your project to build properly, but it leaves you with a dummy google-play-services project in your Eclipse workspace, and it doesn't properly link Eclipse to the Google Play Services Javadocs.

Here's what I did instead:

  1. Install the Google Play Services SDK using the instructions in the Android Maps V2 Quick Start referenced above, or the instructions to Setup Google Play Services SDK, but do not follow the instructions to add Google Play Services into your project.

  2. Right click on the project in the Package Explorer, select Properties to open the properties for your project.

  3. (Only if you already followed the instructions in the quick start guide!) Remove the dependency on the google-play-services project:

    • Click on the Android category and remove the reference to the google-play-services project.

    • Click on the Java Build Path category, then the Projects tab and remove the reference to the google-play-services project.

  4. Click on the Java Build Path category, then the Libraries tab.

  5. Click Add External JARs... and select the google-play-services.jar file. This should be in [Your ADT directory]\sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs.

  6. Click on the arrow next to the new google-play-services.jar entry, and select the Javadoc Location item.

  7. Click Edit... and select the folder containing the Google Play Services Javadocs. This should be in [Your ADT directory]\sdk\extras\google\google_play_services\docs\reference.

  8. Still in the Java Build Path category, click on the Order and Export tab. Check the box next to the google-play-services.jar entry.

  9. Click OK to save your project properties.

Your project should now have access to the Google Play Services library, and the Javadocs should display properly in Eclipse.

b1tw153
  • 379
  • 4
  • 3
  • when I do this, just adding the jar and excluding any references to the imported project, as other posts suggest, my project can't reference anything within the library; won't compile due to errors. How are you getting around that? – wkhatch Sep 18 '13 at 20:40
  • This does not allow you to reference the `@integer/google_play_services_version` value needed for the `meta-data` tag in the manifest. – Chris Feist Mar 10 '14 at 02:36
  • This won't let the maps to execute ! – Devrath Dec 13 '14 at 13:09
11

What i have done is that import a new project into eclipse workspace, and that path of that was be

android-sdk-macosx/extras/google/google_play_services/libproject/google-play-services_lib

and add as library in your project.. that it .. simple!! you might require to add support library in your project.

Sandeep Dhull
  • 1,638
  • 2
  • 18
  • 30
4

Be Careful, Follow these steps and save your time

  1. Right Click on your Project Explorer.

  2. Select New-> Project -> Android Application Project from Existing Code

  3. Browse upto this path only - "C:\Users**your path**\Local\Android\android-sdk\extras\google\google_play_services"

  4. Be careful brose only upto - google_play_services and not upto google_play_services_lib

  5. And this way you are able to import the google play service lib.

Let me know if you have any queries regarding the same.

Thanks

Gaurav Arora
  • 8,282
  • 21
  • 88
  • 143
  • LongMiles I am trying to import google play services and facing difficulty in importing it. It says that " No projects are found to import. Could you please help me regarding this? – bhejaFry Jun 04 '13 at 02:26
  • Just follow my above specified steps, AS IT IS and your problem will definitely be solved. – Gaurav Arora Jun 04 '13 at 04:14
  • I'm using Titanium Studio, and I can't see any Android menu after click Import or in project's properties... – ivy Nov 12 '13 at 07:51
3

Some of the solutions described here did not work for me. Others did, however they produced warnings on runtime and javadoc was still not linked. After some experimenting, I managed to solve this. The steps are:

  1. Install the Google Play Services as recommended on Android Developers.

  2. Set up your project as recommended on Android Developers.

  3. If you followed 1. and 2., you should see two projects in your workspace: your project and google-play-services_lib project. Copy the docs folder which contains the javadoc from <android-sdk>/extras/google/google_play_services/ to libs folder of your project.

  4. Copy google-play-services.jar from <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/libs to 'libs' folder of your project.

  5. In google-play-services_lib project, edit libs/google-play-services.jar.properties . The <path> in doc=<path> should point to the subfolder reference of the folder docs, which you created in step 3.

  6. In Eclipse, do Project > Clean. Done, javadoc is now linked.

maksuti
  • 129
  • 7