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:
- Look In so many webs HowTo's
- create "libs" folder in the android project.
- add my JAR (manually)
- then I went to Java Build Path and checked that my JAR was included to the Android Dependences.
- 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.
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.
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
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:
- Don't use packacges that in android are not allowed
- Look in which version is builded the solution.
来源:https://stackoverflow.com/questions/15793324/android-java-lang-noclassdeffounderror-after-import-jar