Error - The import com.google can not be resolved - android

I am new to android development. I got an error when I wrote the code
import com.google.android.maps.MapView;
in eclipse. The error is The import com.google can not be resolved.
Please anybody give suggestion to fix this problem.

Bring up your project properties, and go to Android. Do you have an Android target selected that includes the Google APIs? Perhaps you just have a generic Android target.

As Jim said, you have to select "Google APIs" (which is Android x.x + Google APIs) instead of something like "Android 2.2" in your project's properties.

First you have to make sure you have installed Google API
Then set your project's properties in Eclipse to check off the Google APIs version of the SDK.
and Make sure you have include this library in AndroidManifest FIle
<uses-library
android:name="com.google.android.maps" />

Related

Android The import com.google cannot be resolved

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

How to import com.google.android package.?

I want to create an activity which will extends MapActivity class.
But I am unable to import com.google.android.maps.MapActivity
It is showing following error:
the import com.google can not be resolved
You have to build you project with Google Api's Library. It looks you are building it with general Android Api.
Do the following steps to get rid of your error.
Right Click on Project ---> Properties ---> Android ---> Select Google
Apis (any api level)--->Click Apply.
Bring up your project properties, and go to Android. Do you have an Android target selected that includes the Google APIs? Perhaps you just have a generic Android target.
First you have to make sure you have installed Google API
Then set your project's properties in Eclipse to check off the Google APIs version of the SDK.
and Make sure you have include this library in AndroidManifest FIle
<uses-library android:name="com.google.android.maps" />

Can not import com.google.android.maps.MapActivity

I try to import com.google.android.maps.MapActivity but my program can not recognize it. I also have <uses-library android:name="com.google.android.maps" />
and set the apiKey in my project.
Can anybody explain why I can import the above line?
Thanks in advance.
What Android Version to you use ? On your project Settings make sure that you use a Project Build Target that contains the google api. Normally they are names "Google APIs".
I included an image of the project settings.
Right click in your project and select Properties, then select Android > Google APIs from Google Inc. version 2.2 or above. Be sure to choose any of the Google APIs instead of the Android 2.2 or above APIs since only Google APIs have the android.maps library.

MapActivity cannot be resolved to a type

I'm busy trying to get the MapView included in my Android project. I'm following the MapView tutorial on the Android developer website but I'm getting an error:
'MapActivity cannot be resolved to a type'
I tried pressing Ctrl+Shift+O to auto import all classes but it's not helping. When I try to include the Maps libary manually it gives this error:
'The import com.google.android cannot be resolved'
I have added the following line (see below) to the Manifest and my target is API 7 (Platform: 2.1).
<uses-library android:name="com.google.android.maps" />
What am I doing wrong?
Thanks!!!
You need to reference correct library at compile time. But what you describe is asking Android to use this specific library at runtime.
You need to right click your Eclipse project, Properties -> Android. In Project Build Target select any target with vendor Google Inc..
Google API is a third party SDK. Choose third party in packages manager.

Help can't import com.google.android.maps

I already tell project use libraries com.google.android.maps in the manifest of project but in my activity it shows errors about importing com.google.android.GeoPoint. and others.
which target version you are using? use target Google apis 1.6 instead of android. You can the change the target version from project itself.
1.Right click on the project
2. choose Build path--> Configure Build path
3.Window will be opened, choose Android in right corner of the window then change target version in to Google apis.
Based on the short described question, i can assume below:
Yes you have mentioned it inside the AndroidManifest.xml file but have you choosen the library instead of SDK while creating android application. If no, then you just need to select Google API (Google Inc.).
You can mention it on the AndroidManifest.xml but first of all choose google api sdk.
First you have to make sure you have installed Google API
Then set your project's properties in Eclipse to check off the Google APIs version of the SDK.
and Make sure you have include this library in AndroidManifest FIle
<uses-library
android:name="com.google.android.maps" />
//in AndroidManifest.xml >>uses-library android:name = "com.google.android.maps"/>
then add maps.jar search for maps.jar and coppy path in your computer
example:C:\Users\android\sdk\add-ons\addon-google_apis-google-17\libs\maps.jar
then right click on your projects >>Build Path >> Configure Build Path..>>Java Build Path>>Libraries taps >>Add External jars..>>past path:C:\Users\android\sdk\add-ons\addon-google_apis-google-17\libs\maps.jar>>choose maps.jar click ok..ends thank you.

Categories

Resources