No virtual method com_polidea_rxandroidble_internal_radio_RxBleRadioImpl$$Lambda$1_lambda$new$0()V

我只是一个虾纸丫 提交于 2020-01-05 07:22:12

问题


I am new in Android Developement and I try to implement Bluetooth LE features on my app. I have some difficulties to run my android project with RXAndroidBLE. This library use lambda and I am not able to make it run.

I have updated my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.maxime.applicationtest"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    testCompile 'junit:junit:4.12'
    compile "com.polidea.rxandroidble:rxandroidble:1.1.0"
}

When I try to run the following code in my MainActivity, an error is displayed:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RxBleClient rxBleClient = RxBleClient.create(this);

        Subscription scanSubscription = rxBleClient.scanBleDevices()
                .subscribe(
                        rxBleScanResult -> {
                            // Process scan result here.
                            Log.e("DEVICE", rxBleScanResult.getBleDevice().getName());
                        },
                        throwable -> {
                            // Handle an error here.
                        }
                );

// When done, just unsubscribe.
        scanSubscription.unsubscribe();
    }
FATAL EXCEPTION: Thread-4847
    Process: com.example.maxime.applicationtest, PID: 27342
        java.lang.NoSuchMethodError: No virtual method com_polidea_rxandroidble_internal_radio_RxBleRadioImpl$$Lambda$1_lambda$new$0()V in class Lcom/polidea/rxandroidble/internal/radio/RxBleRadioImpl; or its super classes (declaration of 'com.polidea.rxandroidble.internal.radio.RxBleRadioImpl' appears in /data/app/com.example.maxime.applicationtest-1/base.apk)
        at com.polidea.rxandroidble.internal.radio.RxBleRadioImpl$$Lambda$1.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:818)

I've no idea why it goes wrong.

If anyone could help me it would be great. Thanks!


回答1:


I finally found a solution by removing jackOptions. Now it works like a charm.




回答2:


Had this problem too. But just removing jackOptions didn't work. Had to add retrolambda to my project. My build gradle now looks like this :

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

buildscript {
    repositories {
        mavenCentral()
    }

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

repositories {
    mavenLocal()
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.trump.islove"
        minSdkVersion 18
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile "com.polidea.rxandroidble:rxandroidble:1.1.0"
    compile 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    testCompile 'junit:junit:4.12'
}



回答3:


you must write to your build.gradle file:

apply plugin: 'me.tatarka.retrolambda'

buildscript {
    repositories {
        mavenCentral()
    }

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


来源:https://stackoverflow.com/questions/41552073/no-virtual-method-com-polidea-rxandroidble-internal-radio-rxbleradioimpllambda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!