我有一个Android Wear应用程序,它在我的Moto360上运行良好。它在Google管理控制台访问Google Play Services和GCM api。然后我试着用另一只手表(LG G watch)。因为我每次只能将一只手表与我的手机配对,所以为了与LG G watch配对,我不得不"忘记"了moto360。现在我似乎无法连接到谷歌应用程序API (GCM或播放服务)。我得到以下错误:
I/GMPM ( 2746): App measurement is starting up
E/GMPM ( 2746): getGoogleAppId failed with status: 10
E/GMPM ( 2746): Uploading is not possible. App measurement disabled
这个错误发生在手表和随附的移动应用程序的日志中。我试着查找状态码,但找不到任何信息。谁能帮我弄清楚这个状态码是什么意思?
将addApi
替换为addApiIfAvailable
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApiIfAvailable(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
我在google的地理围栏例子中遇到了同样的问题。这是由位置和可穿戴API版本不匹配造成的,如下图所示。
dependencies {
compile "com.android.support:support-v4:23.0.0"
compile "com.android.support:support-v13:23.0.0"
compile "com.android.support:cardview-v7:23.0.0"
compile 'com.google.android.gms:play-services-location:7.3.0'
compile 'com.google.android.gms:play-services-wearable:7.8.0'
compile 'com.android.support:support-v13:23.0.1'
wearApp project(':Wearable')
}
验证您的构建。
我遇到了同样的错误,它在客户端实例化中解决了:
GoogleApiClient mGoogleClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
并确保重写这些类:
@Override
protected void onStart(){
super.onStart();
if (!mResolvingError) { // more about this later
mGoogleClient.connect();
}
}
@Override
protected void onStop(){
mGoogleClient.disconnect();
super.onStop();
}
@Override
public void onConnected(Bundle bundle) {
Log.d(TAG, "Connected");
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.d(TAG, "Failed to connect");
}
我使用Log。D测试连接