Android The import com.google cannot be resolved - android

I'm trying to test LocationService example of Android developer as per following link http://developer.android.com/training/location/retrieve-current.html. At that time, error message show me that "The import com.google cannot be resolved" for following 5 lines. I'm really confused how to solve this problem.
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;

You will need the Google Play Services SDK configured within Eclipse and import google play services as library will dismiss this error .

There is a much simpler solution. In my case, I've gone through all the answers from a few sources and none of them give a straight answer to my problem. Finally, I found a sample app source code and when I import the source code I found out adding the library from Google Play Service Library directory solved it. Google Play Service Library is located (for windows user) here:
\sdk\extras\google\google_play_services\libproject
Import the library into Eclipse as a library project and add this library in your actual project will fix it.
EDIT: This guy made a great contribution on his tutorials how to use Android Google Map v2 step by step and very details. It also includes how to use with Android Support package’s backport of fragments.
http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part1

Assuming you use Eclipse.
Right-click on your project -> properties -> Android.
There use Google API's instead of standard Android.

If you're using Android Studio:
Right click on your app folder -> Open Module Settings -> Dependencies -> Click on the plus button -> Choose library dependency -> Search for "play-services" -> Double click on the com.google.android.gms:play-services
Press Ok and wait for Gradle to rebuild.

You can use this way. First of all close projects which are using google-play-services library. Whenever your mouse over the com.google.android.gms import that can not be resolved and towards the bottom of the popup menu, select the "Fix project setup" option as below. Then it'll prompt to import the google-play-services library.

If you're using Eclipse, you can fix this by installing Google Play Services SDK via the SDK Manager, load the google-play-services-lib project into Eclipse, and set this as a reference from your project. This is documented at http://developer.android.com/google/play-services/setup.html

Do you use android sdk with google api? If not, do that and it will work.

set your project properties to google api.

You will need the Google Play Services SDK configured within Eclipse.

Maybe useful for some other developers facing this error:
If you are changing to a newer Android Version and if you are using the android-support-library, you have to beware that all projects that you use as library also have the SAME version of the android-support-library. One example would be the actionbar-sherlock. ;)

It Works = Do you use android sdk with google api? If not, do that and it will work.

In project.properties I had to add the following (for ANT build):
android.library.reference.1=${root_prefix}/${sdk.dir}/extras/google/google_play_services/libproject/google-play-services_lib

If you are using Android studio you may be missing to add gradle to your project.
Add specific play service you want.
Here you may want to compile
com.google.android.gms:play-services-location:10.2.1
Add this to your build.gradle app module in dependencies.

In android studio,add dependency as follows:
In gradle script,go in build.gradle(Module:app) and add these lines
compile 'com.google.android.gms:play-services:10.0.1' in dependencies tag
Here 10.0.1 may be skipped or changed according to your library installed

Related

The import com.google.android.gms.ads cannot be resolved

I am getting error when i want to import google-play-service in Eclipse.
i have import google-play-service-project-lib in Eclipse
i have read all possible Q&A but nothing is work.
I have it added as Library and JAR manually
Then I have tried to clean my project ...
Is there anybody who can solve this problem?
You can use this way. First of all close projects which are using google-play-services library. Whenever your mouse over the com.google.android.gms import that can not be resolved and towards the bottom of the popup menu, select the "Fix project setup" option as below. Then it'll prompt to import the google-play-services library.
Firstly, try to download latest version of Google Play Services, then:
Remove the existing library to add again manually,
Go to your java build path,
Under project tab add your library and then,
Under order & export tab tick your library,
Apply settings.
After all, just clean the project and library, it should work.
By the way, you can also check this question.
To me it was just a matter of updating the dependencies.
dependencies {
implementation 'com.google.android.gms:play-services-ads:20.6.0'
}
I concluded that if it's already on the latest version, refresh the Gradle may solve the issue - or, as already recommended by Umit Kaya, remove the existing library and add it back.

import com.google.android.gms.location.ActivityRecognitionResult cannot be cannot be resolved

I was working on the latest Google API for detected activity. So Inorder to try that I download the sample code from
http://developer.android.com/training/location/activity-recognition.html
I imported the google-play-service-lib. have set it as a library for my project. I have also checked for required permissions, but I am still getting an error. I have also set target build to Google APIs
import com.google.android.gms.location.ActivityRecognitionResult cannot be cannot be resolved.
I was able to import other samples from google play services folder and they are running fine. Can anyone point out what error I am making ?
Ok I was able to fix it,....after reinstalling and adding and removing google play services for several times.
R u sure added the googleplayservices library if added check both are in same folder(path) are not by opening the project -> properties -> resource

com.google.android.gms. No completion available

Im trying to create my first Google Map app and so i'm following this tutorial:
check_Tutorial there you will see the following imports:
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
My problem is when i get to this point i can not add these imports because when i type them they don't appear as if they even exist!! so that's why i can not continue with my map and i've tried so many times with other tutorials they always appear in order the maps works...
If you know the reason why i can not add these imports please let me know 'cause is driving me crazy!!
Error adding the library!
I forgot to tell you that i receive this image a couple of sec after having added the google play services library:
Please install Google Play Service in your device from Google play store.
and also include libraries in your project.
In Eclipse:
File->Import-> Android-> Existing Android Code into Workspace->Browse-> adt->sdk->extras->google->google_play_services->lib Project.
Click OK,
Remember to check option to import libs into workspace.
add the libraries to the project. Clean the Project and Run.
Reason not import(package) google map library in your project
1)You are not selected Android build Target as google API
->Your project right click properties select as google apis
2)You are not added google play service lib in your project(as Is Library)
->Your project right click properties select as google apis.
Install in your device-
https://play.google.com/store/apps/details?id=com.google.android.gms
You need to reference google play services library project in your android project.
Follow the steps #
http://developer.android.com/google/play-services/setup.html
If using eclipse IDE check this
Importing google-play-service library showing a red X next to this reference android

How To Import Google Play service in Eclipse ADT?

I use ADT Eclipse for Progrmming android.And Now I Want Use New Google APi for maps and use Google Play service.Now when Import Libary in Eclipse and added in my Project it's Error:
http://p30droid.com/Uploader/do.php?img=132
http://developer.android.com/google/play-services/maps.html
How to Resolve This Problem..thanks
The specific error you have at the moment is that you are missing a library project in your application project. At a guess - you may not have imported that library into your workspace or you may not have defined it as a library (you tick "is library" in the library project itself).

GoogleAuthUtil cannot be resolved

I am using Google Play Service's Authorization with GoogleAuthUtil in my Android applcation. I did this part about 2 months back, its been working perfectly fine then onwards. Yesterday, I updated the SDK. Now I am getting this error in my application. It says "GoogleAuthUtil cannot be resolved".
Has anything changed in the updated SDK?
How can I solve this?
I am importing the following:
import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.gms.auth.GoogleAuthUtil;
import com.google.android.gms.auth.GooglePlayServicesAvailabilityException;
import com.google.android.gms.auth.UserRecoverableAuthException.
I am getting
com.google.android.gms.auth cannot be resolved.
Whenever you update any library make sure to first remove it from your references and again add it to your references. After that clean the project. Restart Eclipse if needed. And I feel then you are good to go!! :)
Just remove the <uses-library> tag from your AndroidManifest.xml and restart and clean everything. For sure it will start running.
If you are using Android Studio follow step below.
Open SDK Manager -> SDK Tool -> click on Google Play service and Apply
Open Module Setting or Project Structure -> on Dependencies tab click on + button -> select 1.Library Dependency ->Select play-services (...) then click OK
Clean your project by Build -> Clean Project

Categories

Resources