2

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:

enter image description here

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.

enter image description here

enter image description here

Shudy
  • 7,806
  • 19
  • 63
  • 98

3 Answers3

3

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.

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

Community
  • 1
  • 1
Entreco
  • 12,738
  • 8
  • 75
  • 95
  • I can see the class City inside the Android Dependencies Folder if i Expand subfolders. The second link It was what I did to add my jar. But it's still not working :( – Shudy Apr 04 '13 at 12:35
3

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.

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
  • That's how I did, but eclipse is giving the same problem (also y cleaned and fixed properties) – Shudy Apr 04 '13 at 12:37
  • Yes, here is the log file: 04-04 14:45:42.211: E/AndroidRuntime(26187): FATAL EXCEPTION: main 04-04 14:45:42.211: E/AndroidRuntime(26187): java.lang.NoClassDefFoundError: com.elias.polygon.City 04-04 14:45:42.211: E/AndroidRuntime(26187): at com.elias.testinsidecity.MainActivity.onStart(MainActivity.java:49) – Shudy Apr 04 '13 at 12:46
  • I can say that my Jar uses another lib called JavaAPIforKml, and it's included in the jar file, because I can see it inside de Android dependencies folder with City.class I don't know if it can cause some problem – Shudy Apr 04 '13 at 12:48
  • i think so.. try to clean your project & try again. – Dhaval Parmar Apr 04 '13 at 12:53
  • Doesn't work yet doing all u said to me. But... in Android, can we use the java.awt.geom.Path2D; java.awt.geom.Point2D; Because can be this imports used in City.class that are giving me the problems??? – Shudy Apr 04 '13 at 14:43
1

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.
Shudy
  • 7,806
  • 19
  • 63
  • 98