0

所以我有这个特定的警告,我使用了脱糖并且这个警告出现了。我的第三方依赖项之一使用它Bifunction,但由于找不到它,应用程序崩溃。我发现可能脱糖没有Bifunction类,所以jackson不能转换它。我必须说它只会在 Android-API 23 marshmallow 上出错,并且在 Android-API >23 设备上运行良好。

编辑如果我将 desugaring 设置为 true 或 false,则会发生此问题,因此我确定Bifunctionjava.util.function.

代码:

List<Message> list;
list = mapper.convertValue(mapList, new TypeReference<List<Message>>() {});

当我尝试在启用 Desugaring 的情况下构建应用程序时出现警告:

Warning in C:\Users\Keivan Shirkoubian\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.9\359e5e4f4784f23beb30ba454b41f6f992e58481\desugar_jdk_libs-1.0.9.jar:java/util/concurrent/ConcurrentHashMap.class:
  Type `j$.$r8$wrapper$java$util$function$BiFunction$-V-WRP` was not found, it is required for default or static interface methods desugaring of `java.lang.Object java.util.concurrent.ConcurrentHashMap.compute(java.lang.Object, $-vivified-$.java.util.function.BiFunction)`

这是崩溃日志,当我尝试将我的 mapList 映射到另一个列表 (List) 时出现。

W/Java7Support: Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added
W/System.err: io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.NoClassDefFoundError: java.util.function.BiFunction
        at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
        at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:126)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:7331)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    Caused by: java.lang.NoClassDefFoundError: java.util.function.BiFunction
        at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
        at java.lang.Class.getDexCacheType(Class.java:476)
        at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:166)
        at java.lang.reflect.Method.getParameterTypes(Method.java:170)
        at java.lang.Class.getDeclaredMethods(Class.java:679)
        at com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1124)
        at com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector._addMemberMethods(AnnotatedMethodCollector.java:110)
        at com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collect(AnnotatedMethodCollector.java:42)
        at com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collectMethods(AnnotatedMethodCollector.java:33)
        at com.fasterxml.jackson.databind.introspect.AnnotatedClass._methods(AnnotatedClass.java:365)
        at com.fasterxml.jackson.databind.introspect.AnnotatedClass.memberMethods(AnnotatedClass.java:305)
        at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._addMethods(POJOPropertiesCollector.java:525)
        at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collectAll(POJOPropertiesCollector.java:309)
        at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getJsonValueAccessor(POJOPropertiesCollector.java:196)
        at com.fasterxml.jackson.databind.introspect.BasicBeanDescription.findJsonValueAccessor(BasicBeanDescription.java:252)
        at com.fasterxml.jackson.databind.ser.BasicSerializerFactory.findSerializerByAnnotations(BasicSerializerFactory.java:346)
        at com.fasterxml.jackson.databind.ser.BasicSerializerFactory.buildMapSerializer(BasicSerializerFactory.java:767)
        at com.fasterxml.jackson.databind.ser.BasicSerializerFactory.buildContainerSerializer(BasicSerializerFactory.java:568)
        at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:196)
        at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:165)
        at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1388)
        at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1336)
        at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:510)
        at com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.findAndAddSecondarySerializer(PropertySerializerMap.java:90)
        at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase._findAndAddDynamic(AsArraySerializerBase.java:306)
        at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:115)
        at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
        at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
        at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3728)
        at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3678)
        at sanay.co.esn.chat_refactor.core.ChatRefactorView.fetchDataFromResponseGroupContentsFromUnreadNew(ChatRefactorView.java:373)
        at sanay.co.esn.chat_refactor.core.ChatRefactorView.fetchGroupContentsFromUnReadNew(ChatRefactorView.java:362)
        at sanay.co.esn.chat_refactor.core.ChatRefactorView.configResponseGetGroupContentsFromUnRead(ChatRefactorView.java:344)
        at sanay.co.esn.chat_refactor.core.ChatRefactorView.configGetGroupContentsFromUnRead(ChatRefactorView.java:329)
        at sanay.co.esn.chat_refactor.core.ChatRefactorView.access$100(ChatRefactorView.java:60)
        at sanay.co.esn.chat_refactor.core.ChatRefactorView$1.onNext(ChatRefactorView.java:165)
        at sanay.co.esn.chat_refactor.core.ChatRefactorView$1.onNext(ChatRefactorView.java:160)
        at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
        at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
        at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
        ... 7 more
    Caused by: java.lang.ClassNotFoundException: Didn't find class "java.util.function.BiFunction" on path: DexPathList[[zip file "/data/app/sanay.co.esn-2/base.apk"],nativeLibraryDirectories=[/data/app/sanay.co.esn-2/lib/arm, /data/app/sanay.co.esn-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
        ... 48 more
        Suppressed: java.lang.ClassNotFoundException: java.util.function.BiFunction
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 50 more
        Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

[编辑] 这里是 build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        multiDexEnabled true
        applicationId "sanay.co.esn"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 3
        versionName "1.0.5"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true

        buildFeatures{
            dataBinding = true
            viewBinding = true
        }


    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
//        debug{
//            minifyEnabled true
//            shrinkResources true
//            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8

        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true

    }
    packagingOptions {
        exclude 'META-INF/library_release.kotlin_module'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation platform('com.google.firebase:firebase-bom:26.3.0')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.0-rc01'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
    implementation 'com.google.firebase:firebase-database:19.5.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation "androidx.preference:preference:1.1.1"

    ///////////dagger
    implementation 'com.google.dagger:dagger:2.26'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.26'

    //////butterKnife
    implementation 'com.jakewharton:butterknife:10.2.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'


    ///////////lombok
    compileOnly 'org.projectlombok:lombok:1.18.12'
    annotationProcessor 'org.projectlombok:lombok:1.18.12'


    ///////////rx
    implementation "io.reactivex.rxjava2:rxjava:2.2.11"
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'


    /////////retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
    implementation "com.squareup.okhttp3:logging-interceptor:4.2.1"


    /////////Glide
    implementation 'androidx.fragment:fragment:1.2.4'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'


    ////////Timber
    implementation "com.jakewharton.timber:timber:4.7.1"


    /////AvLoading
    implementation "com.wang.avi:library:2.1.3"


    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"


    /////Room
    implementation "androidx.room:room-runtime:2.2.5"
    annotationProcessor "androidx.room:room-compiler:2.2.5"
    testImplementation "androidx.room:room-testing:2.2.5"


    ///////indicator
    implementation "com.github.hrskrs:InstaDotView:1.1"


    implementation 'com.github.massoudss:waveformSeekBar:1.1.4'

    implementation 'com.github.Adilhusen:circle-progress-ad-android-:1.0'
    implementation 'com.github.devendroid:ReadMoreOption:1.0.2'
    implementation 'com.github.chrisbanes:PhotoView:2.1.4'


    implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'

    implementation 'com.airbnb.android:lottie:3.4.0'
    implementation 'com.download.library:Downloader:4.1.4'


    implementation 'com.google.android.exoplayer:exoplayer:2.11.3'
    implementation 'com.google.android.exoplayer:exoplayer-core:2.11.3'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.3'




    //folding cell
    implementation 'com.ramotion.foldingcell:folding-cell:1.2.3'


    implementation 'com.github.dariushm2:PersianCaldroid:1.0.1'

    implementation 'com.github.TutorialsAndroid:FilePicker:v8.0.19'

    implementation 'org.apache.commons:commons-lang3:3.6'
    implementation 'org.apache.commons:commons-io:1.3.2'

    implementation 'com.microsoft.signalr:signalr:5.0.2'
    implementation 'org.slf4j:slf4j-jdk14:1.7.25'

    implementation 'com.github.aliab:Persian-Date-Picker-Dialog:1.5.2'

    implementation 'com.google.firebase:firebase-messaging:21.0.1'
    implementation 'com.google.firebase:firebase-analytics:18.0.1'

    // for stream support in old Android versions
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'

    implementation "androidx.tonyodev.fetch2:xfetch2:3.1.5"

    implementation 'ch.acra:acra-http:5.7.0'

    implementation "ch.acra:acra-mail:5.7.0"


    /* for refresh  */
    implementation 'com.cjj.materialrefeshlayout:library:1.3.0'

    /* for expandable layout in group Info*/
    implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'

    implementation "org.java-websocket:Java-WebSocket:1.5.1"

    implementation 'com.squareup.picasso:picasso:2.5.2'

    /* library for crash reporting to file*/
    implementation 'com.balsikandar.android:crashreporter:1.1.0'

    api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

    implementation 'com.github.zomato:androidphotofilters:1.0.2'

    /* for security of application */
    implementation 'com.github.framgia:android-emulator-detector:1.4.0'
    implementation 'com.github.mukeshsolanki:Android-Tamper-Detector:0.0.2'

    /* for selecting multiple files */
    implementation 'com.github.jaiselrahman:FilePicker:1.3.2'

    /* for CameraX*/
    implementation "androidx.camera:camera-camera2:1.0.0-rc04"
    implementation "androidx.camera:camera-lifecycle:1.0.0-rc04"
    implementation "androidx.camera:camera-view:1.0.0-alpha23"

    /* SSLPinning */
    implementation 'com.ibm.icu:icu4j:69.1'

}

这是另一个:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.4.32'

    repositories {
        google()
        jcenter()

        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}



allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url "https://maven.google.com" }
        maven { url "https://jitpack.io" }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
4

1 回答 1

0

java.util.function 包中的BiFunction要求您的项目模块与 Java 8 兼容。

尝试将您的 Gradle 插件升级到版本 3.0.0(或更高版本)并添加 Java 8 语言功能支持。检查文档链接

如果您已经这样做了,请分享您的 Gradle 配置文件。

于 2021-05-09T13:55:06.180 回答