我在android中开发应用程序时遇到问题,我想知道是否有人可以提供任何帮助。
Iam在Android中开发了一个应用程序,可将英语段落转换为马拉雅拉姆语。为此,我正在使用opennlp库。我也在使用像en-sent.bin,en-token.bin这样的opennlp模型。我使用“ en-parser-chunking.bin”模型解析一个句子,以生成解析后的句子,如下所示。
(顶部(S(NP(NN Programcreek))(VP(VBZ是)(NP(DT a)(ADJP(RB
      非常)(JJ巨大)(CC和)(JJ有用))))(。网站。)))
我在netbeans中得到正确的解析句子,但是在android中却出现错误。错误是这样的。

06-10 08:11:55.420: W/dalvikvm(1623): threadid=1: thread exiting with uncaught exception (group=0xb3ad6b90)
***06-10 08:11:55.440: E/AndroidRuntime(1623): FATAL EXCEPTION: main
06-10 08:11:55.440: E/AndroidRuntime(1623): Process: com.example.opennlp1, PID: 1623
06-10 08:11:55.440: E/AndroidRuntime(1623): java.lang.NoClassDefFoundError: opennlp.model.GenericModelReader
06-10 08:11:55.440: E/AndroidRuntime(1623):     at opennlp.tools.util.model.GenericModelSerializer.create(GenericModelSerializer.java:35)***
06-10 08:11:55.440: E/AndroidRuntime(1623):     at opennlp.tools.util.model.GenericModelSerializer.create(GenericModelSerializer.java:31)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at opennlp.tools.util.model.BaseModel.loadModel(BaseModel.java:231)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at opennlp.tools.util.model.BaseModel.<init>(BaseModel.java:181)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at opennlp.tools.sentdetect.SentenceModel.<init>(SentenceModel.java:95)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at com.example.opennlp1.MainActivity.SentenceDetect(MainActivity.java:52)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at com.example.opennlp1.MainActivity.onCreate(MainActivity.java:33)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at android.app.Activity.performCreate(Activity.java:5243)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
06-10 08:11:55.440: E/AndroidRuntime(1623):     at android.os.Handler.dispatchMessage(Handler.java:102)


谁能帮助我解决错误?

最佳答案

当Java虚拟机在运行时无法找到编译时可用的类时,通常会发生此错误。为了修复它,请检查项目中的.classpath文件,可能是类路径中缺少添加的jar文件。在.classpath文件中自己编写路径,程序应该可以工作。

查看此链接:
http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-in.html

关于java - java.lang.NoClassDefFoundError:opennlp.model.GenericModelReader,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24141401/

10-12 02:46