bluetooth-lowenergy - 在 RxAndroidBLE 上获取客户端时出错

标签 bluetooth-lowenergy rxandroidble

我无法获取客户端。 我正在开始 Android 开发,所以也许这是一个配置/新手错误,但我尝试/搜索的任何东西都不起作用。 每次我调用“RxBleClient.create(context);”时,都会收到以下错误:

FATAL EXCEPTION: Thread-34217
Process: es.ralcaidev.arduinobt, PID: 15488
java.lang.IncompatibleClassChangeError: The method 
'void com.polidea.rxandroidble.internal.radio.RxBleRadioImpl.com_polidea_rxandroidble_internal_radio_RxBleRadioImpl_lambda$new$0()' 
was expected to be of type direct but instead was found to be of type virtual 
(declaration of 'com.polidea.rxandroidble.internal.radio.RxBleRadioImpl' 
appears in /data/app/es.ralcaidev.arduinobt-2/base.apk)
at com.polidea.rxandroidble.internal.radio.RxBleRadioImpl.access$lambda$0(Unknown)
at com.polidea.rxandroidble.internal.radio.RxBleRadioImpl$$Lambda$1.run(Unknown)
at java.lang.Thread.run(Thread.java:818)

我已切换到 JDK 1.8 并在 gradle 上启用了 Jack。

有什么想法吗?

最佳答案

我遇到了完全相同的问题。正如 s_noopy 所说,https://github.com/Polidea/RxAndroidBle/issues/33帮我解决了。

问题是 Java 8 lambda 不能与 RxAndroidBle 一起使用。您必须使用retrolambda,因为它兼容的API 版本。这就是出现神秘消息指出传递了错误参数的原因。

在你的 build.gradle 文件中,删除 jackOptions 闭包(我相信它可以在 defaultConfig 闭包中找到)并使其看起来像这样:

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'
    }
}

android {

如果它能解决您的问题,请告诉我。

关于bluetooth-lowenergy - 在 RxAndroidBLE 上获取客户端时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38922648/

相关文章:

swift - 在 RxBluetoothKit 中链接多个命令

android - Rxandroid ble 重连处理指南

android - 低功耗蓝牙 : Reading the sensor in RedBearLab Arduino Shield from Raspberry Pi

bluetooth - 使用 bluez/bluetoothctl/gatttool 连接到蓝牙智能/LE 体重秤

ios - 如何在后台扫描 BLE 设备?

c# - Windows 10 API 中的蓝牙低功耗广告数据限制

java - 日志: Queue's awaitRelease() has been interrupted abruptly while it wasn't released byte release() method

android - 如何从扫描的 BLE 设备中读取原始数据?

ios - 没有服务的 BLE 设备的三个 UUID,这可能吗?

rxandroidble - 如何在 RxAndroidBle 中接收所有通知