【问题标题】:Android Wear: Unable to connect to GmsClient com.google.android.gms.LIGHTWEIGHT_INDEXAndroid Wear:无法连接到 GmsClient com.google.android.gms.LIGHTWEIGHT_INDEX
【发布时间】:2016-01-21 01:03:58
【问题描述】:

我正在 Android Wear 上使用 Data Layer,它试图将 DataItem(使用 Data API)从 Wearable (Moto 360 Gen1) 发送到我的移动设备。

但是,没有出现错误或连接失败的迹象,并且没有发送数据。我收到的唯一消息错误是

E/Gms 客户端:无法连接到服务:com.google.android.gms.icing.LIGHTWEIGHT INDEX SERVICE'

在移动设备中:

我创建了一个 Wearable Listener Service 来接收onDataChanged(DataEventBuffer dataEvents)中的数据

Android 清单

<service
        android:name=".ListenerService">
    <intent-filter>
        <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
    </intent-filter>
</service>

穿着活动:

Activity 的头部看起来像

public class MainActivity extends WearableActivity implements
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener{

我的 onCreate(..) 函数中有一个 GoogleApiClient:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(AppIndex.API).build();

mGoogleApiClient.connect();

@Override
public void onConnected(Bundle bundle) {
    Log.d("Android Wear Connection", "" + mGoogleApiClient.isConnected());

    //Data Layer Function uses Data Map
    sendAmplitudeDb(10, 2300);
}

我真的卡住了,不知道为什么移动设备没有收到任何数据项,或者为什么可穿戴设备无法连接到 Google Api 客户端...请帮助!

另外,我已经实现了与以下 git repo 几乎相同的代码: https://github.com/LarkspurCA/WearableDataMap

【问题讨论】:

    标签: wear-os google-api-client android-wear-data-api dataitem


    【解决方案1】:

    我遇到了类似的问题,我最终找到了解决方案,我禁用了在设置数据项之前执行的所有连接验证调用。事实证明,我在移动设备上没有 DataReading/ListenerService(实际上我根本没有移动应用程序,因为我正在使用表盘)。

    检查您是否在项目中导入了 import com.google.android.gms.* 并且您正在建立连接或验证它以建立设备之间的通信,而其他设备没有侦听器服务

    【讨论】:

      【解决方案2】:

      确保服务标签在清单中的应用标签内,也许?

      【讨论】:

      • 如果你在客户端把你的 AppIndex api 注释掉,一切正常吗?
      • @AliNaddaf 是的,在我删除 .addApi(AppIndex.API) 后它运行良好。这真是我的愚蠢错误..非常感谢! :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多