I am trying to use java.awt.polygon class in android programming. In Java build paths, I have added
Jave JRE System library jdk 1.7
.
However while using this piece of code
java.awt.Polygon polyGon = new Polygon();
i get error NoClassDefFoundError. How can I use java class in android?
That is not possible, as that class does not exist in Android.
That will not work, as that class does not exist in Android. While you have added it to your build path, it is not included in the APK and is not in the operating system.
Find the source for the class, refactor it into your own package (e.g.,
org.umar.Polygon), and add it to your project, then use your refactored version. Along the way, please respect the license for the class (e.g., GPL if you are using OpenJDK).