我正在使用Lucene开发一个移动的应用程序。当我使用BooleanQuery
时,它可以正常工作。但当我使用WildcardQuery
或FuzzyQuery
时,我在运行时得到一个java.lang.NoClassDefFoundError。我知道android Studio默认支持maven。我检查了外部库和所有添加的jar。我的build.gradle文件具有以下依赖项:
compile group: 'org.apache.lucene', name: 'lucene-core', version: '7.0.1'
compile group: 'org.apache.lucene', name: 'lucene-analyzers-common', version: '7.0.1'
compile group: 'org.apache.lucene', name: 'lucene-codecs', version: '7.0.1'
compile group: 'org.apache.lucene', name: 'lucene-queryparser', version: '7.0.1'
compile group: 'org.apache.lucene', name: 'lucene-queries', version: '7.0.1'
compile group: 'org.apache.lucene', name: 'lucene-sandbox', version: '7.0.1'
未找到类定义错误:
Process: com.example.eren.lucene, PID: 7215
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/ClassValue;
at org.apache.lucene.search.MultiTermQuery.getTermsEnum(MultiTermQuery.java:300)
at org.apache.lucene.search.MultiTermQueryConstantScoreWrapper$1.rewrite(MultiTermQueryConstantScoreWrapper.java:141)
at org.apache.lucene.search.MultiTermQueryConstantScoreWrapper$1.bulkScorer(MultiTermQueryConstantScoreWrapper.java:193)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:655)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:462)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:581)
at org.apache.lucene.search.IndexSearcher.searchAfter(IndexSearcher.java:439)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:450)
at com.example.eren.lucene.MainActivity.searchIngredient(MainActivity.java:262)
at com.example.eren.lucene.MainActivity.searchProcess(MainActivity.java:216)
at com.example.eren.lucene.MainActivity.onCreate(MainActivity.java:48)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.lang.ClassValue" on path: DexPathList[[zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/base.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.eren.lucene-zYmMwtI9UFJUuvVsCJY1Gw==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.apache.lucene.search.MultiTermQuery.getTermsEnum(MultiTermQuery.java:300)
at org.apache.lucene.search.MultiTermQueryConstantScoreWrapper$1.rewrite(MultiTermQueryConstantScoreWrapper.java:141)
at org.apache.lucene.search.MultiTermQueryConstantScoreWrapper$1.bulkScorer(MultiTermQueryConstantScoreWrapper.java:193)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:655)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:462)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:581)
at org.apache.lucene.search.IndexSearcher.searchAfter(IndexSearcher.java:439)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:450)
at com.example.eren.lucene.MainActivity.searchIngredient(MainActivity.java:262)
at com.example.eren.lucene.MainActivity.searchProcess(MainActivity.java:216)
at com.example.eren.lucene.MainActivity.onCreate(MainActivity.java:48)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
有什么办法解决这个问题吗?
1条答案
按热度按时间b4qexyjb1#
Android并不完全支持java8的特性(请参阅https://developer.android.com/studio/write/java8-support)。Lucene在java 6上的最新版本是4.7。Lucene 4.7与Android的兼容性理论上是好的。