-1

hello i am quite new to Android development and i want to learn how to use the google Maps API v2. After trying numerous tutorials, i always seem to have a problem with the google play services library. Somehow, Eclipse can't import it properly. I tried this tutorial https://github.com/thecodepath/android_guides/wiki/Google-Maps-Fragment-Guide and when i try to include Google Play Services project as a library, first it all goes nice and smooth, i get a green tick in the Project Properties - Android - Library window, but when i close it i still get lots of "can't be resolved to a type" errors. I return to the window where i add the library and i see a red "X" and a question mark under "project" instead of the green tick. I tried several other tutorials and i always have a problem with this library. I like this tutorial and i would really like to make it work. I also tried to manually copy the library folder in the workspace but that didn't work either. I googled like crazy trying to find an answer but i always find something that i tried before (like manually copying the library in the workspace or something similar). I am quite desperate, i really have no idea why it can't just see the library please help. Also this is my first post to StackOverflow so be gentle :)

later Edit (solved): when i imported the downloaded project, i kept it on the desktop and thats why it didn't work, after i copied it in the workspace everything worked. Thank you all very much for helping a beginner :)

ChrisX
  • 334
  • 1
  • 5
  • 20

5 Answers5

4

The important thing in adding a library in eclipse is to remember that your project and the library project need to be in the same workspace.

To solve this follow below ways,

You can copy the google-play-services library project to the same workspace where your main project is there.

else

While importing the library to eclipse remember to check copy projects into workspace which will add a copy of the library to your workspace.

enter image description here

Spring Breaker
  • 8,233
  • 3
  • 36
  • 60
2

I see a red "X" and a question mark under "project" instead of the green tick.

The problem is -

The path to your google play services library is not same as the path to your project. It is outside of your project. And so is not recognized by simple import.

Solution - Put the library in the project's libs folder.

NOTE: Just putting the library to the libs folder is not enough.

After you added your library follow these steps -

1) Go to Project -> Properties -> Java Build Path -> Libraries -> Add JARs..

2) Now add your recently added jar to the build path from JAR selection process.

3) Go to Project -> Properties -> Java Build Path -> Order and Export.

4) Put a tick mark in the check box against this library name and press OK.

5) Do Project -> Clean.

sjain
  • 23,126
  • 28
  • 107
  • 185
  • i put the google-play-services_lib folder inside the libs folder and still didn't work – ChrisX Jul 15 '14 at 10:10
  • @Cristi - You need to do `Project -> Clean` after the addition. Then build your project and check. – sjain Jul 15 '14 at 10:11
  • i did a clean and it is set to build automatically so i suppose it should work, but it still doesn't work – ChrisX Jul 15 '14 at 10:17
  • @Cristi - Check my update on how to import the library after adding it to `libs` folder. – sjain Jul 15 '14 at 10:20
0

if your giving google-Play-Service-lib as a references to your project , try to keep your project and the Google-play services lib should be in same drive.

if your project is on C: drive means place Google-play-services-lib in C:

Rajesh Mikkilineni
  • 854
  • 10
  • 22
0

While making the copy of the entire folder libproject containing google-play-services_lib from eclipse import project by selecting the copied libproject folder in your working place.

For the rest follow the steps in Setting Up Google Play Services

Sagar Sakre
  • 2,336
  • 22
  • 31
0

Eclipse

  • Copy the library project at

<android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/

to the location where you maintain your Android app projects.

  • Import the library project into your Eclipse workspace. Click

File > Import, select Android > Existing Android Code into Workspace

and browse to the copy of the library project to import it.

  • After you've added the Google Play services library as a dependency for your app project, open your app's manifest file and add the following tag as a child of the <application> element:
< meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

Android Studio

  • Open the build.gradle file inside your application module directory.
  • Add a new build rule under dependencies for the latest version of play-services eg
    ...
    dependencies {
        compile 'com.google.android.gms:play-services:9.2.0'
    }
apply plugin: 'com.android.application'

Source developers.google.com

sivaBE35
  • 1,876
  • 18
  • 23