【发布时间】:2014-09-16 10:51:31
【问题描述】:
我正在尝试在 Android Wear 和 Android 手机之间建立连接。 googleApiClient 连接失败,并返回 SERVICE_VERSION_UPDATE_REQUIRED 状态码。 我做错了什么?
这是我的活动代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
int conResult = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if(conResult!=ConnectionResult.SUCCESS){
Log.e(LOG_TAG,"Google play services are not available on this device");
}
googleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
googleApiClient.connect();
}
这是我在 wear 文件夹中的 build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example"
minSdkVersion 20
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.support:wearable:+'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:5.+'
}
还有我的 AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example" >
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault" >
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
【问题讨论】:
-
您可以查看我的问题:stackoverflow.com/questions/35786083/… 在我使用新版本的 Play Service sdk 时 -> 无法连接 Google Api 客户端。我应该使用 6.5.87 版本;
-
我认为问题可能与安卓模拟器有关
标签: android google-play-services wear-os