Android java.lang.NoClassDefFoundError after import JAR

安稳与你 提交于 2019-12-06 11:23:42

问题


I got a problem...

I made a Jar (called "GeoFence.jar"), that I have to use on a Android Project. So, what I done is:

  1. Look In so many webs HowTo's
  2. create "libs" folder in the android project.
  3. add my JAR (manually)
  4. then I went to Java Build Path and checked that my JAR was included to the Android Dependences.
  5. finally I made the necessary Imports to use the class I need from JAR.

After do all of this, I runned my App, and it throws this error:

and I don't understand what's going on, cause, I Fixed the Project Properties and cleaned it. And it's still not working.

Here is how i have the structure and the build path.


回答1:


for adding jar use below two stpe: but for you just do 2nd.

1. Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar -> yourjar.jar
2. Your Project -> right click -> Properties -> Java Build Path -> Order & Export --> Select All --> OK

After taht just clean your Project and RUN.




回答2:


If you go to you Android Dependencies folder, you should be able to expand the GeoFence.jar file. This way, you should be able to find the class com.elias.polygon.City if you keep expanding subfolders.

If you CANNOT see it, you probably made an error in exporting the jar file.

  • To solve the export see this question on so

If you CAN see the class, you have an error in your build path/ project properties

  • To solve the project setup, see this question



回答3:


the problem that I had, was that the jar I wanted to import, used some packages that in android are not "allowed" so I had to do in a different way.

After that, it happens the same, but the problem was that the Jar was Build in v1.7. When I builded in v1.6 android accepted it.

So, first of all look for:

  1. Don't use packacges that in android are not allowed
  2. Look in which version is builded the solution.


来源:https://stackoverflow.com/questions/15793324/android-java-lang-noclassdeffounderror-after-import-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!