Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The import com.google.android.gms.location.LocationClient cannot be resolved after formatting computer

I formatted my computer and again imported my android project which has been done using Google Maps API V2 and found out many errors.I re-linked google_play_services_lib and android-support-v7-appcompat.I still find an error in importing com.google.android.gms.location.LocationClient.Only the call of "LocationClient" gives an error and others are imported fine.

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
(ERROR)import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

and find errors everywhere I have used R. calling. error : R cannot be resolved to a variable

setContentView(R.layout.activity_main); EditText et = (EditText) findViewById(R.id.editText1);

and getting the following errors in the console.

[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:121: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:119: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:116: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:117: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:155: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:157: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:158: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:156: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:153: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:154: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:192: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:194: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:195: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:193: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:190: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
[2014-12-19 23:22:44 - MapsProject] 
[2014-12-19 23:22:44 - MapsProject] C:\Users\Sudesh\Android_Workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:191: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
[2014-12-19 23:22:44 - MapsProject] 
like image 649
SNT93 Avatar asked Dec 19 '14 18:12

SNT93


1 Answers

LocationClient was deprecated a while ago and apparently was removed from Play Services recently. You will need to switch to using GoogleApiClient to get the LocationServices.API. This sample project demonstrates how to do this. Basically:

Step #1: Set up a GoogleApiClient data member of whatever is using the API:

private GoogleApiClient client=null;

Step #2: Request the LocationServices.API:

client=new GoogleApiClient.Builder(host)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

Step #3: In onConnected() of your GoogleApiClient.ConnectionCallbacks, start using LocationServices.FusedLocationApi to work with locations (e.g., call getLastLocation())

like image 58
CommonsWare Avatar answered Sep 27 '22 23:09

CommonsWare