1

私は AndroidStudio を使用しており、ジオコードに googleplayservices を使用しようとしています。

私はアンドロイドチュートリアルに従いました: http://developer.android.com/google/play-services/setup.html

しかし、私のインポートでは下線が引かれています: import android.location. LocationClient ; つまり: シンボル Location Client を解決できません

何か案は?

私のコードは次のようになります:

//imports
...
import android.location.Location;
import com.google.android.gms.location.LocationClient;
import android.location.LocationClient;
...

build.grandle

...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile files('libs/android-async-http-1.4.6.jar')
    compile 'com.google.android.gms:play-services:6.5.87'
}
...

そして最後に私のxmlマニフェスト:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.name.application_name" >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
    <uses-permission android:name="android.permission.READ_LOGS"/>
    ....
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
            <activity
    ....
4

2 に答える 2

2

There is no LocationClient in package android.location. This is why your import is resulting in an error.

In fact, the LocationClient class is deprecated. From Google Play Services | Android Developers:

非推奨のクライアント - 、、ActivityRecognitionClientおよびLocationClientクラスPlusClientは非推奨です。アプリでこれらの API を使用していて、Google Play サービス 6.5 以降の API を呼び出したい場合は、を利用する新しいプログラミング モデルに切り替える必要がありますGoogleApiClient。の使用方法の詳細については、「 Google API へのアクセスGoogleApiClient」を参照してください。

非推奨の API の代わりに、次の API を使用してください。

...以前に を使用していた場合は、代わりにパッケージLocationClient内の API を呼び出します。com.google.android.gms.location

LocationClientからへの移行に関する簡単な情報については、「 android - LocationClient クラスが Google Play サービス rev 22 に見つからないGoogleApiClient」を参照してください。

于 2015-02-26T04:00:01.730 に答える