4

I'm making a game where I'm using Google Play Services. I recently switched from eclipse to Android Studio (now running 0.8.14). In android studio I added a "Google Play Services Activity" and had my game class extend that class. I left the services class without modification. The project compiles and runs just fine but the IDE is filled with errors because it "cannot resolve symbol 'common'" and "cannot resolve symbol 'games'"

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;

Any ideas on why this is and how to fix it?

I have attempted to reimport my project after deleting all .iml files and the .idea folder without result.

[EDIT]

As per request I'm adding a screenshot of the errors:

Screenshot of the code window

[EDIT 2]

I've kept searching for solutions and while I have not found any, I now have a screenshot that may be a bit more helpful.

enter image description here

As you can see, the com.google.android.gms package seems to be missing the common and games package.

I have tried updated gradle, tried using JDK 1.7 instead of 1.8 and attempted syncing with gradle multiple times. I will keep searching for an answer but if you have experienced this before, please feel free to help me and others out.

Felix ZY
  • 674
  • 6
  • 14
  • In what way is the IDE "filled with errors" if it's compiled correctly? An error of "cannot resolve symbol" sounds like a compiler error to me... – Jon Skeet Oct 30 '14 at 10:07
  • For example: `protected GoogleApiClient mGoogleApiClient;` : GoogleApiClient is marked red with the message "cannot resolve symbol 'GoogleApiClient'" since android studio can't find the imports. Why it compiles and runs is beyond me - I've never seen it happen before. – Felix ZY Oct 30 '14 at 10:12
  • That sounds like it's *not* compiling - if the IDE is showing errors, they're compile-time errors. It may be allowing you to try to run code despite the errors, but that doesn't mean that it compiled properly... – Jon Skeet Oct 30 '14 at 10:13

2 Answers2

3

Add this to your build.gradle

dependencies {
     compile 'com.google.android.gms:play-services:5.0.89'
}
Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
1

Finally I found the real problem. Apparantly, my project was contained in a folder that ended with an exclamation mark. (myProjectName!) This caused Android studio to fail in finding certain imports.

Solution: I renamed my project from myProjectName! to myProjectName and moved the whole project to a new folder without the trailing exclamation mark. This seems to have fixed everything.

Felix ZY
  • 674
  • 6
  • 14
  • Oh, that was my problem root cause too. Unfortunately, I didn't spot your answer until I fixed through my own stackoverflow post http://stackoverflow.com/questions/32477067/android-studio-cannot-resolve-symbol-syntax-highlighting-errors-although-bui. – Jim C Sep 17 '15 at 01:09