LocationClient无法正常导入Google Play服务

时间:2015-01-26 15:46:11

标签: java android gps

我需要一些帮助,因为我在使用Google Play服务时遇到了一些错误。 我必须更新现有的应用程序;该应用程序功能齐全,它使用了GPS提供的一些功能。 今天我从BitBucket下载了应用程序的代码,当我导入它时,LocationClient出错了。 我再次按照谷歌的指示确保一切正常,但我仍然收到以下错误:

LocationClient cannot be resolved to a type

在这堂课中:

package com.racsa.oncecincocinco;

import android.location.Location;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
import com.google.android.gms.*;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;

public class ActivityRacsaLocalizador extends FragmentActivity implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener{

    private static final String TAG = "ActivityRacsaLocalizador";

    // These settings are the same as the settings for the map. They will in fact give you updates
    // at the maximal rates currently possible.
    private static final LocationRequest REQUEST = LocationRequest.create()
            .setInterval(5000)         // 5 seconds
            .setFastestInterval(16)    // 16ms = 60fps
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    private LocationClient clienteLocalizacion;


    @Override
    protected void onStart() {
        super.onStart();
        inicializarClienteLocalizacionSiEsNecesario();
        clienteLocalizacion.connect();
    }

    @Override
    protected void onStop() {

        if (clienteLocalizacion != null) {

            if (clienteLocalizacion.isConnected()){
                clienteLocalizacion.removeLocationUpdates(this);
            }

            clienteLocalizacion.disconnect();
        }

        super.onStop();
    }

    private void inicializarClienteLocalizacionSiEsNecesario() {
        if (clienteLocalizacion == null) {
            clienteLocalizacion = new LocationClient(
                    getApplicationContext(),
                    this,  // ConnectionCallbacks
                    this); // OnConnectionFailedListener
        }
    }


    public Location getLocalizacionActual() {
        Location miLocalizacion = null;

        if (clienteLocalizacion != null && clienteLocalizacion.isConnected()) {
            miLocalizacion = clienteLocalizacion.getLastLocation();
        }

        return miLocalizacion;
    }

    @Override
    public void onConnected(Bundle connectionHint) {
        clienteLocalizacion.requestLocationUpdates(
                REQUEST,
                this);
    }

    @Override
    public void onDisconnected() {
        // Do nothing
    }

    @Override
    public void onConnectionFailed(ConnectionResult result) {
        // Do nothing
    }


    /**
     * Implementation of {@link LocationListener}.
     */
    @Override
    public void onLocationChanged(Location location) {
        // Do nothing
    }
}

我不知道发生了什么,请帮助我!

编辑: 这是清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.racsa.oncecincocinco"
    android:installLocation="auto"
    android:versionCode="20"
    android:versionName="3.0" >

    <uses-sdk android:minSdkVersion="8" />

    <permission
        android:name="com.racsa.oncecincocinco.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" >
    </permission>

    <uses-permission android:name="com.racsa.oncecincocinco.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.flash"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.front"
        android:required="false" />

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="false"
        android:smallScreens="false" />

    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/icono_launcher"
        android:label="@string/app_name" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyAYGybtYRnkT5x5BvPjx7r0nBHVBwRXI90" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />


        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name="com.racsa.oncecincocinco.Splash"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.racsa.oncecincocinco.Principal"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.Preferencias"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MostrarAnunciante"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.SimpleOptionMenu"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.ActivityMenuHolder"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MenuLista"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.RegistroUsuario"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MostrarAnuncianteInfo"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.CrearComentario"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.ListaComentario"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MostrarInfoComentario"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.CrearLista"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MisListas"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MisListasTest"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.BuscarListas"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MostrarListasBuscar"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MisListasAgregarAnunciante"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MostrarListasInfo"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MostrarListasInfoBuscar"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.MapaGuia"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.Promocion"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.VerInfoPromocion"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.ListaPromocion"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity android:name="com.racsa.oncecincocinco.ActivityEscogerPlan" android:screenOrientation="portrait">
        </activity><activity
            android:name="com.racsa.oncecincocinco.ActivityMostrarMapa"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.ActivityFiltrarRealidadAumentada"
            android:screenOrientation="portrait"
            android:theme="@style/StyledIndicators" >
        </activity>
        <activity
            android:name="com.racsa.oncecincocinco.ActivityLanzarRealidadAumentada"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleInstance">
        </activity>

        <service
            android:name="com.octo.android.robospice.JacksonSpringAndroidSpiceService"
            android:exported="false" />

        </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

问题解决了! 我对GPS进行了降级,现在已经有效了。 下次我进行更新时,imma会将版本更改为最新版本。