2

サンプル ( https://developers.google.com/fit/android/ble-sensors ) のコードに従いましたが、次のエラーが発生します。

private void buildFitnessClient() {
    // Create the Google API Client
    mClient = new GoogleApiClient.Builder(this)
        .addApi(Fitness.API)
        .addScope(FitnessScopes.SCOPE_ACTIVITY_READ)
        .addScope(FitnessScopes.SCOPE_BODY_READ)
        .addScope(FitnessScopes.SCOPE_LOCATION_READ)
        .addConnectionCallbacks(
                new GoogleApiClient.ConnectionCallbacks() {
                    @Override
                    public void onConnected(Bundle bundle) {
                        Log.i(TAG, "Connected!!!");
                        buildBle();  // Scan for BLE Devices.
                    }

                    @Override
                    public void onConnectionSuspended(int i) {
                        // ..
                    }
                }
        )
        .addOnConnectionFailedListener(
                new GoogleApiClient.OnConnectionFailedListener() {
                    // ..
                }
        )
        .build();
}

private void buildBle() {
    BleScanCallback callback = new BleScanCallback() {
        @Override
        public void onDeviceFound(BleDevice device) {
            ClaimBleDeviceRequest request = new ClaimBleDeviceRequest.Builder()
                .setDevice(device)
                .build();
            PendingResult<Status> pendingResult =
                    Fitness.BleApi.claimBleDevice(mClient, request);
        }
        @Override
        public void onScanStopped() {
            // ..
        }
    };

    StartBleScanRequest request = new StartBleScanRequest.Builder()
        .setDataTypes(DataTypes.HEART_RATE_BPM)
        .setBleScanCallback(callback)
        .build();

    PendingResult<Status> pendingResult =
        Fitness.BleApi.startBleScan(mClient, request);

}

@Override
protected void onCreate(Bundle savedInstanceState) {
    // ..
    buildFitnessClient();
}

buildBle()メソッドを呼び出すと、次のエラーが発生します。

09-29 12:38:27.777: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:27.777: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:27.777: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:27.777: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:27.777: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:27.777: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:27.777: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:28.794: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:28.794: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:28.794: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:28.794: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:28.794: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:28.794: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:28.794: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:29.801: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:29.802: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:29.802: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:29.802: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:29.802: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:29.802: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:29.802: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:31.816: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:31.817: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:31.817: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:31.817: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:31.817: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:31.817: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:31.817: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:32.845: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:32.845: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:32.845: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:32.845: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:32.845: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:32.845: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:32.845: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:33.842: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:33.854: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:33.854: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:33.854: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:33.854: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:33.854: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:33.854: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:34.847: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:34.848: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:34.848: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:34.848: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:34.848: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:34.848: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:34.848: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:35.849: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:35.856: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:35.856: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:35.856: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:35.856: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:35.856: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:35.856: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)
09-29 12:38:36.275: W/Parcel(5900): **** enforceInterface() expected 'com.google.android.gms.fitness.ble.IBleScanCallback' but read 'com.google.android.gms.fitness.request.IBleScanCallback'
09-29 12:38:36.276: W/Binder(5900): Caught a RuntimeException from the binder stub implementation.
09-29 12:38:36.276: W/Binder(5900): java.lang.SecurityException: Binder invocation to an incorrect interface
09-29 12:38:36.276: W/Binder(5900):     at android.os.Parcel.nativeEnforceInterface(Native Method)
09-29 12:38:36.276: W/Binder(5900):     at android.os.Parcel.enforceInterface(Parcel.java:453)
09-29 12:38:36.276: W/Binder(5900):     at com.google.android.gms.fitness.ble.d$a.onTransact(Unknown Source)
09-29 12:38:36.276: W/Binder(5900):     at android.os.Binder.execTransact(Binder.java:404)

助けてください。ありがとう。

4

3 に答える 3

0

これを GoogleApiClient ビルダーに追加してみてください:

.addApi(Fitness.BLE_API)
于 2015-05-11T12:38:56.490 に答える