Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio cannot resolve symbol common

I followed the migration guide from Eclipse to Android Studio carefully and the only error that I am getting is "cannot resolve symbol common" and is happening on these lines:

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;

Does anyone know why this would be happening?

like image 919
charles young Avatar asked May 26 '13 18:05

charles young


People also ask

What is Cannot resolve symbol in Android Studio?

Most often “R cannot be resolved” error appears if there is an issue with some of your resource files. Due to this error, you are unable to build your application. That's why we need to solve this error as it not getting away by just doing a simple restart or hitting Alt+Enter.

What does Cannot resolve symbol mean?

As before cannot resolve symbol means the java compiler cannot find the symbol it shows you on the symbol line. In this case it cannot find a method called Println for the object out .


1 Answers

The build tool (gradle) can't find the google_play_services library, that define the relevant classes. Update your build.gradle file, so that it finds the library (at the right path):

[EDIT 2: since 6.5, you can selectively add needed Google Play Services APIs ]

dependencies {
    compile 'com.google.android.gms:play-services-base:9.4.0'
    compile 'com.google.android.gms:play-services-XXX:9.4.0'
}

[EDIT: newer method, a 'native' support is now provided]

Open SDK Manager, download and install Google Play Services and Google Repository Edit build.gradle to add:

dependencies {
    compile 'com.google.android.gms:play-services:3.1.36'
}

[Old method]

Check that google-plays-services is a module in your project, and that its build.gradle contains:

dependencies {
    compile files('libs/google-play-services.jar')
}

In your module build.gradle:

dependencies {
     compile project(':google-play-services')
}
like image 118
etienne Avatar answered Oct 18 '22 00:10

etienne