没有静态方法元工厂(OptaPlanner) [英] No static method metafactory (OptaPlanner)

查看:132
本文介绍了没有静态方法元工厂(OptaPlanner)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我在我的build.gradle中添加了OptaPlanner依赖项,以使用库的车辆路径问题.当我尝试使用求解器时,收到以下错误

Recently I added OptaPlanner dependency to my build.gradle in order to use the Vehicle Routing Problem of the Library. When I tried to use the solver I received the following error

java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)

我有google,发现我需要启用JDK 1.8,就像我在build.gradle中所做的一样,但是它似乎并没有消失.我也附上了build.gradle文件.有什么建议 ? (我正在使用Android-Studio)

I have google and found that I need to enable JDK 1.8 for the same which I have done in the build.gradle however it still doesn't seem to go away. I am attaching the build.gradle file as well. Any suggestions ? (I am using Android-Studio)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.example.groceryrouter"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/kie.conf'
        exclude 'META-INF/ErraiApp.properties'
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation group: 'com.jtransc', name: 'jtransc-rt', version: '0.6.8'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation "androidx.cardview:cardview:1.0.0"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.1'
    implementation 'androidx.navigation:navigation-ui:2.2.1'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.gms:google-services:4.3.3'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha02'
    implementation 'com.google.android.libraries.places:places:2.2.0'
    // https://mvnrepository.com/artifact/commons-io/commons-io
    implementation group: 'commons-io', name: 'commons-io', version: '20030203.000550'
    implementation('org.optaplanner:optaplanner-core:7.36.0.20200331') {
        exclude group: 'xmlpull'
        exclude group: 'org.drools'
        // todo exclude, didn't work on optaplanner 6.1.0
        //exclude group: 'org.kie'
    }
    // Required -- JUnit 4 framework
    testImplementation 'junit:junit:4.12'
    // Optional -- Robolectric environment
    testImplementation 'androidx.test:core:1.0.0'
    // Optional -- Mockito framework
    testImplementation 'org.mockito:mockito-core:1.10.19'
    implementation "org.slf4j:slf4j-simple:1.7.9"
}

推荐答案

我认为您正在使用getter注释.请改用字段注释.

I presume you're using getter annotations. Use field annotations instead.

这是我们使用MethodHandles而不是反射来调用getter的改进,它们更快,但是在Android和Graal上存在兼容性问题.

It's an improvement we made to use MethodHandles instead of reflection to call getters, and they are faster, but it has compatibility issues on Android and Graal.

这篇关于没有静态方法元工厂(OptaPlanner)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆