1

I am using Eclipse for my programming. When I write programs in java project, everything was ok. Then, I copy a class to Android project and it is missing some imports:

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

I search on google for the jar file and find out java-rt-jar-stubs-1.5.0.jar on website http://www.java2s.com/Code/Jar/j/Downloadjavartjarstubs150jar.htm

However, when I add the library in project (Right click on project -> Build path -> Configure build path -> Java Build Path -> Tab Libraries (added needed libraries) and Tab Order and Export (check on those libraries)), it cause me an error: Conversion to Dalvik format failed with error 1.

Does anyone knows how to fix it? Please help me!

Luong Truong
  • 1,953
  • 2
  • 27
  • 46
  • yes.. You *most probably* have a conflict condition.. Check if there are multiple Jars (usually third party Jars) with the same class or incompatible JAR(s). – TheLostMind Jul 07 '14 at 07:01
  • Thank you for your comment. I check the libraries, there is only one file jar name: java-rt-jar-stubs-1.5.0.jar. When I remove it, the error do not display anymore. I guess that in android project, we cannot use those imports? – Luong Truong Jul 07 '14 at 07:26

2 Answers2

0

There seems to be no ImageIO or AWT libraries available for Android and I don't think you can add them with java-rt-jar-stubs-1.5.0.jar (what is it BTW?). You will likely need to convert the code to use standard imaging classes provided by Android, like BitmapFactory and Bitmap.

pingw33n
  • 12,292
  • 2
  • 37
  • 38
0

As mentioned in the comments section , this most probably occurs due to conflicts in jars (same class names or package names inside different jars).. Please check this thread:
"Conversion to Dalvik format failed with error 1" on external JAR

Community
  • 1
  • 1
Hussein Terek
  • 588
  • 9
  • 13