7

I am trying to migrate a project from Eclipse to Android Studio, the project can be build in Eclipse and was successful imported to Android Studio, however, I get Cannot resolve symbol 'GooglePlayServicesClient' error in Android Studio.

I followed the official tutorial to imported Google Play service in Android Studio, and an other package "com.google.android.gms.common.ConnectionResult" that used in my project does not have same issue. Only 'GooglePlayServicesClient' cannot be resolved.

issue

I have also tried clean and rebuild my project, but the problem persists. What am I doing wrong?

Update:

My build.gradle

...
dependencies {
    compile project(':libraryListViewAnimations')
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/commons-net-3.1-sources.jar')
    compile files('libs/commons-net-3.1.jar')
    compile files('libs/mail.jar')
}
TRX
  • 465
  • 1
  • 8
  • 17
  • Did you take a look in your .classpath /. iml file? Can you see this dependency? Did you try to refresh dependencies in IDE? In which scope does it happen? (main / test or runtime) – CyberAleks Mar 26 '15 at 08:22
  • Sorry, I am new in Android Studio. Where is the .classpath / .iml file? I just found `dependencies { classpath 'com.android.tools.build:gradle:1.1.2' }` inside my project `build.gradle` file. Is it correct? Should I add dependencies of my module `build.gradle` to my project `build.gradle`? – TRX Mar 26 '15 at 08:29
  • Sure you should add your dependecies in build.gradle. But your IDE use a plugin that reads this dependecies and writes it to the classpath file. I guess the new Android Studio based on Intellij so you should look for .iml. You can find it in your project root folder. The .classpath (Eclipse) or .iml (Idea) are actually hidden. – CyberAleks Mar 26 '15 at 08:37
  • After copy dependencies of my module build.gradle to the project build.gradle, I got `Gradle DSL method not found: compile()` error. – TRX Mar 26 '15 at 08:45
  • Watch this video. https://www.youtube.com/watch?v=2q7XGuH2Q-s Maybe it can be helpful. – CyberAleks Mar 26 '15 at 08:52
  • possible duplicate of [Cannot resolve symbol GooglePlayServicesClient on new Android Studio Project](http://stackoverflow.com/questions/29303427/cannot-resolve-symbol-googleplayservicesclient-on-new-android-studio-project) – Fabricator Apr 30 '15 at 23:21
  • @fabricator I asked earlier than him... :/ – TRX May 01 '15 at 01:31

2 Answers2

11

GooglePlayServicesClient is obsolete and no longer included in the Google Play Services 7.x library. Google recommends using the GoogleApiClient instead.

See Accessing Google APIs in the Android developer docs:

"Note: If you have an existing app that connects to Google Play services with a subclass of GooglePlayServicesClient, you should migrate to GoogleApiClient as soon as possible."

Devon Biere
  • 2,992
  • 1
  • 23
  • 32
0

Did you add compile 'com.google.android.gms:play-services:7.0.0' to build.gradle? You can find more guide here . Hope this help.

MichaelP
  • 2,761
  • 5
  • 31
  • 36
  • Yes, I have this line in my build.gradle file. – TRX Mar 26 '15 at 07:25
  • i'm not sure why, but i saw it's duplicate two lines compile. You should choose latest version 'com.google.android.gms:play-services:+' compile 'com.google.android.gms:play-services:7.0.0' – MichaelP Mar 26 '15 at 07:27
  • i just checked com.google.android.gms.common and saw class GooglePlayServicesClient. i'm not sure why you don't. Just get latest version and sync build gradle again. – MichaelP Mar 26 '15 at 07:43
  • 1
    Do you have any result on this ? – Mathieu de Brito Mar 30 '15 at 15:21