我正在使用Lucene开发移动应用程序。当我使用BooleanQuery
时,它可以工作。但是当我使用WildcardQuery
或FuzzyQuery
时,我在运行时获得了java.lang.NoClassDefFoundError。我知道android studio默认支持maven。我检查了外部库和添加的所有罐子。
我的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'
NoClassDefFound错误:
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)
有什么想法解决这个问题吗?
答案 0 :(得分:0)
Android不完全支持java8功能(请参见https://developer.android.com/studio/write/java8-support)。 Lucene在Java 6上的最新版本是4.7。从理论上讲,Lucene 4.7与android的兼容性很好。