java - IncompleteClassChangeError ...原本应该是 direct 类型,但结果却发现是 virtual 类型

标签 java lambda rx-java

我正在使用 RxJava,现在我尝试通过提供 lambda 来订阅可观察对象:

observableProvider.stringForKey(CURRENT_DELETED_ID)
    .subscribe(str -> this.elementDeleted(str));

问题是,我收到这个有趣的错误:

方法“void elementDeleted(String)”预计为 direct 类型,但结果发现为 virtual 类型(“java.lang.reflect.ArtMethod”的声明出现在/system/framework/中) core-libart.jar)

该函数如下所示:

private elementDeleted(String elemId) {
    // removing element from some lists
    this.updateView();
}

有帮助的是将函数 elementDeleted(String) 设置为 public,但随后我在调用函数 updateUser 时遇到相同的错误。因此,为了解决这个问题,我必须将从该点调用的所有函数设置为公共(public)。这不可能是解决方案。

即使我尝试提供这样的函数引用:

observableProvider.stringForKey(CURRENT_DELETED_ID)
    .subscribe(this::elementDeleted);

没用。我认为它甚至无法与公共(public)功能一起使用。

希望你能帮助我。

编辑 这是我的 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'dexguard'

android {

    buildToolsVersion '24.0.1'
    compileSdkVersion 24

    defaultConfig {
        applicationId "com.myapp.isthebest"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 380
        versionName "0.1.8"

        renderscriptTargetApi 18
        renderscriptSupportModeEnabled true

        vectorDrawables.useSupportLibrary = true

    }

    buildTypes {
        debug {
            proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
            proguardFile 'proguard-project.pro'
            proguardFile 'proguard-project-debug.pro'
            ndk {
                abiFilters = ['armeabi-v7a', 'x86']
            }
            jniDebuggable true
        }
        release {
            proguardFile getDefaultDexGuardFile('dexguard-release-aggressive.pro')
            proguardFile 'proguard-project.pro'
            proguardFile 'proguard-project-release.pro'
            signingConfig signingConfigs.release
            lintOptions {
                disable 'MissingTranslation'
            }
            ndk {
                abiFilters = ['armeabi-v7a']
            }
        }
        beta {
            proguardFile getDefaultDexGuardFile('dexguard-release-aggressive.pro')
            proguardFile 'proguard-project.pro'
            proguardFile 'proguard-project-release.pro'
            proguardFile 'proguard-project-beta.pro'
            signingConfig signingConfigs.release
            lintOptions {
                disable 'MissingTranslation'
            }
            ndk {
                abiFilters = ['armeabi-v7a']
            }
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
    }

    dataBinding {
        enabled = true
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    lintOptions {
        abortOnError false
    }

}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:recyclerview-v7:24.1.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'org.functionaljava:functionaljava:4.4'
    compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'com.squareup.picasso:picasso:2.6.0-20161009.170155-29'
    compile 'com.appyvet:materialrangebar:1.3'
    compile 'com.google.code.gson:gson:2.4'
    compile 'commons-codec:commons-codec:1.10'
    compile 'commons-io:commons-io:2.4'
    compile 'org.apache.commons:commons-collections4:4.1'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.amazonaws:aws-android-sdk-core:2.2.20'
    compile 'com.amazonaws:aws-android-sdk-cognito:2.2.20'
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.20'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.2.20'
    compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.20'
    compile 'net.hockeyapp.android:HockeySDK:4.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'us.feras.mdv:markdownview:1.1.0'
    compile 'ly.count.android:sdk:16.06.03'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
    compile 'com.nulab-inc:zxcvbn:1.1.4'
    compile 'com.neovisionaries:nv-websocket-client:1.30'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.github.pwittchen:reactivenetwork:0.5.2'
    testCompile 'com.squareup.retrofit2:retrofit-mock:2.1.0'
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.0'
    testCompile 'org.mockito:mockito-core:1.9.5'
    testCompile 'org.powermock:powermock-module-junit4:1.6.1'
    testCompile 'org.powermock:powermock-api-mockito:1.6.1'
    provided 'com.google.auto.value:auto-value:1.2'
    apt "com.google.auto.value:auto-value:1.2"

    apt 'com.ryanharter.auto.value:auto-value-gson:0.4.3'
    provided 'com.ryanharter.auto.value:auto-value-gson:0.4.3'

    compile 'com.google.dagger:dagger:2.7'
    apt "com.google.dagger:dagger-compiler:2.7"
    provided 'javax.annotation:jsr250-api:1.0'
    compile 'javax.inject:javax.inject:1'
    testCompile 'com.google.dagger:dagger:2.7'
    testApt "com.google.dagger:dagger-compiler:2.7"
    testProvided 'javax.annotation:jsr250-api:1.0'
    testCompile 'javax.inject:javax.inject:1'
    compile files('libs/dexguard-runtime.jar')
    compile ':securekeyboard-runtime:@aar'
}

afterEvaluate {
    dexguardRelease.logging.level = 'INFO'
}

最佳答案

我看到你正在为android构建,所以问题可能如下:构建集minSdkVersion 21 - android 5 lollipop AND targetCompatibility for java 8 - 从sdk 24开始受支持(尽管非常有限),从而导致你的构建问题。您可以通过三种方式解决此问题:

1) 为 minSdkVersion 24 构建,目标固定 0.4% 设备数量

2) 摆脱 java 8 功能并将源/目标兼容性设置为 java 7

3) 使用 java 8 功能并使用 retrolambda 进行构建(有一些限制,存在于 lib 自述文件中)

关于java - IncompleteClassChangeError ...原本应该是 direct 类型,但结果却发现是 virtual 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41246673/

相关文章:

c# - Moq:如何在 linq 中调用方法谓词来模拟查询?

c++ - 将 lambda 与 sigc 库结合使用

rx-java - 将 Observable<Something> 映射到 Observable<Void>

java - 为什么我的 fragment 在我的 View 页面中重新初始化?

java - dwr反向ajax股票演示应用程序

c++ - 是否可以根据 lambda 采用的参数数量专门化采用 lambda 表达式的模板函数?

java - RxJava : merge() changes the order of the emitted items?

kotlin - 为什么Rx会打印整个数组而不是每个项目

java - 是否可以在 Eclipse 中设置项目范围的 VM 参数

java - 如何在此代码中显示负数阶乘