Is there Kotlin documentation at all? I'm getting a Bluetooth Exception I need help debugging

I tried to get Acceleration data out of my MetaMotion R and I'm getting a bluetooth exception I don't quite understand.

` fun startGettingAccelerationData() {
try {
accelerometer = metaWearBoard.getModule(
Timber.d("METAWEAR Accelerometer: %s", accelerometer)
.odr(AccelerometerBmi160.OutputDataRate.ODR_25_HZ) // set odr to 25Hz
.range(AccelerometerBosch.AccRange.AR_4G) // set range to +/-4g

        accelerometer.acceleration().addRouteAsync {  }

        accelerometer.acceleration().addRouteAsync(RouteBuilder { source ->
   : Subscriber {
                override fun apply(data: Data?, vararg env: Any?) {
                    data?.let {
                        val acceleration: Acceleration = it.value(
                        Timber.d("METAWEAR - Data %s", acceleration.toString())
        }).continueWith(object : Continuation<Route, Void> {
            override fun then(task: Task<Route>): Void? {
                return null
    } catch (exception: Exception) {

And here's the exception I get when I try to run it this way:

2019-08-13 00:44:50.682 21820-21962/ W/BluetoothGatt: Unhandled exception in callback java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter env at com.testapp.sample.MetawearSensorReceiver$startGettingAccelerationData$1$1.apply(Unknown Source:7) at at com.mbientlab.metawear.impl.StreamedDataConsumer.lambda$addDataHandler$4( at com.mbientlab.metawear.impl.-$$Lambda$StreamedDataConsumer$b3JFDLkGI0Pi2mtR2I-nobGuhUc.onResponseReceived(Unknown Source:4) at com.mbientlab.metawear.impl.JseMetaWearBoard.lambda$null$17( at com.mbientlab.metawear.impl.-$$Lambda$JseMetaWearBoard$OnC0yYpmZcKMMHqzlWEtJ-kw-x8.onChange(Unknown Source:2) at$1.onCharacteristicChanged( at android.bluetooth.BluetoothGatt$1$ at android.bluetooth.BluetoothGatt.runOrQueueCallback( at android.bluetooth.BluetoothGatt.access$200( at android.bluetooth.BluetoothGatt$1.onNotify( at android.bluetooth.IBluetoothGattCallback$Stub.onTransact( at android.os.Binder.execTransact(


  • edited August 2019

    Stack trace tells you what is wrong.
    kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter env at com.testapp.sample.MetawearSensorReceiver$startGettingAccelerationData$1$1.apply(Unknown Source:7)

  • I'm having the same issue. The Subscriber interface defines the apply method like this:
    void apply(Data data, Object ... env);

    But then seems to proceed to invoke it with null for the second parameter. Question is why this is happening. This parameter apparently is influenced by the route creation. But I haven't seen anything in the documentation that would have an effect...

  • According to this SO answer:
    it could also be a null return value. No idea though how this would be the case here, as apply does not return anything...

  • @calfilmmaker Have you solved this issue?

  • Ok, seems this was an issue with creation of the subscriber. The way it works for me:

    dataProducer?.addRouteAsync { { data, env ->
            // do stuff with data and env here

    I don't really know why it works this way and not if you implement subscriber and do though...

Sign In or Register to comment.