gpt4 book ai didi

java - 无静态方法元工厂(OptaPlanner)

转载 作者:行者123 更新时间:2023-12-01 17:30:45 26 4
gpt4 key购买 nike

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

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)

我谷歌了一下,发现我需要启用 JDK 1.8,就像我在 build.gradle 中所做的那样,但它似乎仍然没有消失。我还附上了 build.gradle 文件。有什么建议 ? (我使用的是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 注释。请改用字段注释。

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

关于java - 无静态方法元工厂(OptaPlanner),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61125845/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com