简体   繁体   English

将外部jar jwordpress-0.5.1.jar添加到eclipse中的android项目

[英]Add external jar jwordpress-0.5.1.jar to android project in eclipse

I add an external jar jwordpress-0.5.1.jar. 我添加了一个外部jar jwordpress-0.5.1.jar。 In logcat I see: 在logcat中,我看到:

  • 12-30 09:34:41.041: E/dalvikvm(379): Could not find class 'net.bican.wordpress.Wordpress', referenced from method ru.androiden.client.MainActivity.onCreate 12-30 09:34:41.041:E / dalvikvm(379):找不到类``net.bican.wordpress.Wordpress'',从方法ru.androiden.client.MainActivity.onCreate引用
  • 12-30 09:34:41.201: E/AndroidRuntime(379): FATAL EXCEPTION: main 12-30 09:34:41.201:E / AndroidRuntime(379):致命意外:主要
  • 12-30 09:34:41.201: E/AndroidRuntime(379): java.lang.NoClassDefFoundError: net.bican.wordpress.Wordpress 12-30 09:34:41.201:E / AndroidRuntime(379):java.lang.NoClassDefFoundError:net.bican.wordpress.Wordpress

I have used several methods to add jar, for example: 我使用了几种添加jar的方法,例如:

What do I do? 我该怎么办? I have already solved this problem for two days. 我已经解决了这个问题两天了。 Regards, Denis. 问候,丹尼斯。

It sounds like the jar file is not being packaged with your application. 听起来 jar文件没有与您的应用程序打包在一起。

ie it's on your eclipse classpath (assuming eclipse's java editor didn't complain about your import statement?) so it's there at compile time. 即它在您的Eclipse类路径上(假设eclipse的Java编辑器没有抱怨您的import语句?),因此它在编译时就在那儿。 BUT the jar file isn't actually being bundled with your app, so the class that you're referencing isn't actually available at runtime. 但是 jar文件实际上并未与您的应用程序捆绑在一起,因此您引用的类实际上在运行时不可用。

To fix this, just create a libs directory in your project and follow the steps that you read to import the jar file from there. 要解决此问题,只需在项目中创建一个libs目录,然后按照阅读的步骤从此处导入jar文件。 This should ensure that the jar gets bundled and its classes are available at runtime. 这应确保将jar捆绑在一起,并且其类在运行时可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM