android 工作室无法解析符号位置客户端
android studio cannot resilve symbol LocationClient
我正在使用 AndroidStudio 并尝试使用 googleplayservices 进行地理编码。
我已按照 android 教程进行操作:
http://developer.android.com/google/play-services/setup.html
但在我的导入中我有下划线:
导入 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
....
包 android.location
中没有 LocationClient
。这就是您的导入导致错误的原因。
事实上,LocationClient
class 已弃用。来自 Google Play Services | Android Developers:
Deprecated clients - The ActivityRecognitionClient
, LocationClient
, and PlusClient
classes are deprecated. If you used those APIs in your app and want to call Google Play services 6.5 or higher APIs, you must switch to the new programming model that utilizes GoogleApiClient
. For more information about using GoogleApiClient
, see Accessing Google APIs.
Use these APIs instead of the deprecated APIs:
...If you were previously using LocationClient
, call the APIs in the com.google.android.gms.location
package instead.
有关从 LocationClient
迁移到 GoogleApiClient
, see android - LocationClient class not found on google play services rev 22
的快速信息
在您的 build.gradle:
添加 google play services older version
compile 'com.google.android.gms:play-services:5.0.89'
我正在使用 AndroidStudio 并尝试使用 googleplayservices 进行地理编码。
我已按照 android 教程进行操作: http://developer.android.com/google/play-services/setup.html
但在我的导入中我有下划线: 导入 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
....
包 android.location
中没有 LocationClient
。这就是您的导入导致错误的原因。
事实上,LocationClient
class 已弃用。来自 Google Play Services | Android Developers:
Deprecated clients - The
ActivityRecognitionClient
,LocationClient
, andPlusClient
classes are deprecated. If you used those APIs in your app and want to call Google Play services 6.5 or higher APIs, you must switch to the new programming model that utilizesGoogleApiClient
. For more information about usingGoogleApiClient
, see Accessing Google APIs.Use these APIs instead of the deprecated APIs:
...If you were previously using
LocationClient
, call the APIs in thecom.google.android.gms.location
package instead.
有关从 LocationClient
迁移到 GoogleApiClient
, see android - LocationClient class not found on google play services rev 22
在您的 build.gradle:
添加 google play services older versioncompile 'com.google.android.gms:play-services:5.0.89'