6

Sformatowałem komputer i ponownie zaimportowałem mój projekt Androida, który został wykonany przy użyciu Google Maps API V2 i dowiedziałem się wielu błędów. Połączone google_play_services_lib i android-support-v7-appcompat.I nadal znajduję błąd podczas importowania com.google.android.gms.location.LocationClient.Tylko wywołanie "LocationClient" powoduje błąd, a inne są importowane dobrze.Importowania com.google.android.gms.location.LocationClient nie można rozwiązać po sformatowaniu komputera.

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; 

i znajduj błędy wszędzie, gdzie używałem wywoływania R. błąd: R nie mogą być rozwiązane do zmiennej

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

i uzyskiwanie następujące błędy w konsoli.

[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

Zobacz [to pytanie] (http://stackoverflow.com/q/27372638/1676363), jak zmienić aplikację na FusedLocationProviderApi. – ianhanniballake

Odpowiedz

15

LocationClient została zaniechana jakiś czas temu i najwyraźniej został usunięty z gry Services niedawno. Aby uzyskać numer LocationServices.API, musisz przełączyć się na używanie GoogleApiClient. This sample project pokazuje, jak to zrobić. Zasadniczo:

Krok 1: Skonfiguruj członek GoogleApiClient danych, co jest za pomocą interfejsu API:

private GoogleApiClient client=null; 

Krok 2: Żąda LocationServices.API:

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

Krok 3: W onConnected() z twojego GoogleApiClient.ConnectionCallbacks, zacznij używać LocationServices.FusedLocationApi do pracy z lokalizacjami (np. Wywołanie getLastLocation())

+0

, co jest z błędami w setContentView (R.layout.activity_main); EditText et = (EditText) findViewById (R.id.editText1); R Nie można rozstrzygnąć na zmienną – SNT93

+0

@ SNT93: Wygląda na to, że używasz 'appcompat-v7', więc musisz ustawić swój cel kompilacji (np. Project> Properties> Android) na API Level 21 lub wyższy. To nie ma nic wspólnego z 'LocationClient'. – CommonsWare

+0

Bardzo dziękuję .. To pomogło .. – SNT93

0

Czy zaimportowałeś bibliotekę Google Play do tego samego folderu? Mam na myśli, że podczas importowania istnieje opcja kopiowania projektu do istniejącego obszaru roboczego. Sprawdź to podczas importowania. enter image description here

+0

Tak, zrobiłem to. Oba odniesienia mają zielone kleszcze – SNT93

0

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

Jeśli chcesz nawiązać połączenie z jednym z interfejsów API Google, pod warunkiem w bibliotece Google Play (takich jak Google+, Gry lub jazda), trzeba utworzyć wystąpienie GoogleApiClient ("Google API Klient"). Klient interfejsu API Google zapewnia wspólny punkt dostępu do wszystkich usług Google Play i zarządza połączeniem sieciowym między urządzeniem użytkownika i każdą usługą Google.

Powiązane problemy