我想制作一个简单的穿戴式应用程序并通过数据层进行连接。一切工作正常与手持模块(使用:S5),但可穿戴(使用:摩托360)总是抛出的错误:Android Wear错误ConnectionResult {statusCode = SERVICE_VERSION_UPDATE_REQUIRED,resolution = null}
onConnectionFailed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null}
在掌上电脑中的播放服务均达到最新
我已经添加了
compile 'com.google.android.gms:play-services:7.3.0'
把这两个手持设备当作磨损build.gradle。
的佩戴活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTextView = (TextView) stub.findViewById(R.id.text);
}
});
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
Log.i(TAG,"Services available: "+ result);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle connectionHint) {
Log.d(TAG, "onConnected: " + connectionHint);
// Now you can use the Data Layer API
}
@Override
public void onConnectionSuspended(int cause) {
Log.d(TAG, "onConnectionSuspended: " + cause);
}
})
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.d(TAG, "onConnectionFailed: " + result);
}
})
// Request access only to the Wearable API
.addApi(Wearable.API)
.build();
}
@Override
protected void onStart() {
super.onStart();
Log.i(TAG, "==OnStart===");
mGoogleApiClient.connect();
}
我已经做了研究,但我找不到任何有效的解决方案。
如果您正在为磨损设备使用仿真器,请确保您的仿真器具有最新的Android版本。我有一个API 22的模拟器,我得到了错误。然后我创建了一个新的API 24(7.0牛轧糖),它的工作。 –