BigJ
BigJ

Reputation: 2032

Add Google Play Services to Eclipse project

I've red a number of posts and articles but it's not working for me. I am not able to add/use the Google Play Services in my project.

My steps:

  1. I start a project which is using the Google Api's 2.2
  2. I have download the Google Play Services using the SDK
  3. I import the Google Play Services into my Eclipse workspace
  4. Adding Google Play Services as a dependency in my project: Project -> Properties -> Android -> Library, Add -> google-play-services_lib

Steps 1 till 3 are fine, but I think the problem is in step 4. Nothing happens after I do step 4, I'm not seeing any change in my Project structure: no library is added. These steps are also described here.

The reason I know it is not working is because any import from the Google Play Services is giving an unresolved error.

Upvotes: 39

Views: 79781

Answers (4)

user3469294
user3469294

Reputation: 101

It took me 2 whole days to work out what was the problem, but now it is resolved.

The problem is with the 64 bit version of ADT and Java. Eclipse does not import libraries correctly with the 64 bit versions.

So I reinstalled Java 6 v 37 jdk (32 bit) and then downloaded the 32 bit version of ADT to go with it. I did this EVEN THOUGH I HAVE A 64 bit system

Anyway, I then followed the exact same procedure that had failed with the 64 bit versions. And it worked perfectly - first time.

So that is my advice - YOU MUST USE A 32 BIT VERSION OF JAVA AND ADT, because the 64 bit contains incompatibility issues with eclipse for importing the Google Play Services Library, and probably other libraries too.

PS. I followed the installation steps for Google Play Services outlined on developer.android.com

I should add that the develop.android site overlooks an important fact - that the map xml should be inside a linear or relative layout. It does not work unless it is inside a container layout such as these

Upvotes: 9

Dragan Marjanović
Dragan Marjanović

Reputation: 2416

I had the same problem and two more additional steps 5-6 solved this on Eclipse Juno 4.2.2:
1. import google-play-services_lib as an existing Android project (check "Copy projects into workspace")
2. clean newly added google-play-services_lib project
3. edit your project properties and add library project to it
4. clean your project
5. restart Eclipse and now there was google-play-services.jar now successfully added
6. I even had to manually add "import com.google.android.gms.common.GooglePlayServicesUtil" in my Java class in order to use GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); because Eclipse didn't offer to add import automatically

Upvotes: 4

GCT
GCT

Reputation: 149

The thing is that you have to modify the manifest.xml file as well. After importing(with copy) into workspace, eclipse will raise an error about the targeted-sdk platform. As default, the manifest file includes only the minimum-sdk-version as 8.

Upvotes: 5

Owen B
Owen B

Reputation: 1184

I found that the play services libproject has to be imported onto the same physical drive as your project. (check the 'Copy projects into workspace' checkbox when you import)

Upvotes: 67

Related Questions