6

Ho formattato il mio computer e importato di nuovo il mio progetto Android che è stato eseguito utilizzando l'API V2 di Google Maps e ho scoperto molti errori. collegato a google_play_services_lib e android-support-v7-appcompat.Trovengo ancora un errore nell'importazione di com.google.android.gms.location.LocationClient. Solo la chiamata di "LocationClient" restituisce un errore e gli altri vengono importati correttamente.L'importazione com.google.android.gms.location.LocationClient non può essere risolta dopo aver formattato il computer

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; 

e trovare errori ovunque io abbia utilizzato R. calling. errore: R non può essere risolto per una variabile

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

e ottenere i seguenti errori nella 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] 
+0

Vedere [questa domanda] (http://stackoverflow.com/q/27372638/1676363) per come passare l'applicazione a FusedLocationProviderApi. – ianhanniballake

risposta

15

LocationClient è stata sconsigliata qualche tempo fa ea quanto pare è stato rimosso dal Play Services di recente. Dovrai passare all'utilizzo di GoogleApiClient per ottenere lo LocationServices.API. This sample project mostra come eseguire questa operazione. In sostanza:

Passo # 1: Impostare un membro di dati GoogleApiClient di tutto ciò che sta utilizzando l'API:

private GoogleApiClient client=null; 

Passo # 2: Richiedere il LocationServices.API:

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

Step # 3: In onConnected() del GoogleApiClient.ConnectionCallbacks, iniziare a utilizzare LocationServices.FusedLocationApi per lavorare con le posizioni (ad esempio, chiamare getLastLocation())

+0

gli errori in setContentView (R.layout.activity_main); EditText et = (EditText) findViewById (R.id.editText1); R non può essere risolto con una variabile – SNT93

+0

@ SNT93: Sembra che tu stia utilizzando 'appcompat-v7', e quindi devi impostare il tuo target di build (ad es. Progetto> Proprietà> Android) a livello API 21 o superiore. Questo non ha nulla a che fare con 'LocationClient'. – CommonsWare

+0

Grazie mille..Ti ha aiutato .. – SNT93

0

Hai importato la libreria di riproduzione di Google nella stessa cartella? Voglio dire quando si importa c'è un'opzione copia il progetto nello spazio di lavoro esistente. Controllalo durante l'importazione. enter image description here

+0

sì, l'ho fatto. Entrambi i riferimenti hanno spuntoni verdi – SNT93

0

Da https://developers.google.com/android/guides/api-client:

Quando si desidera effettuare una connessione ad una delle API di Google fornito nella biblioteca di Google Play Services (come Google+, giochi, o Drive), è necessario crea un'istanza di GoogleApiClient ("Cliente dell'API di Google "). Il client dell'API di Google fornisce un punto di accesso comune a tutti i servizi di Google Play e gestisce la connessione di rete tra il dispositivo dell'utente e ciascun servizio Google.