Hi to all.
I’m having a problem with the imports. It’s showing me errors on the imports and if I remove them the JpegImageMetadata, Sanselan, ImageReadException, TiffImageMetadata, ExifTagConstants can’t be resolved to a type.
I’m using Android 2.3.3 and also tried Android 3.2, still had the same problem. Here are the imports:
import org.apache.sanselan.ImageReadException;
import org.apache.sanselan.Sanselan;
import org.apache.sanselan.formats.jpeg.JpegImageMetadata;
import org.apache.sanselan.formats.tiff.TiffImageMetadata;
import org.apache.sanselan.formats.tiff.constants.ExifTagConstants;
And this is the other part of the code that is showing the error (I can post the whole code if needed):
private int degreeRotated(String filePath) {
try {
JpegImageMetadata meta = ((JpegImageMetadata) Sanselan.getMetadata(new File(filePath)));
TiffImageMetadata data = null;
if (meta != null) {
data = meta.getExif();
}
int orientation = 0;
if (data != null) {
orientation = data.findField(ExifTagConstants.EXIF_TAG_ORIENTATION).getIntValue();
} else {
String[] projection = { Images.ImageColumns.ORIENTATION };
Cursor c = getContentResolver().query(Uri.fromFile(new File(filePath)), projection, null, null, null);
if (c != null && c.moveToFirst()) {
orientation = c.getInt(0);
}
}
switch (orientation) {
case 6:
return 90;
case 8:
return 270;
default:
return 0;
}
/*
* } catch (JpegProcessingException e1) { e1.printStackTrace(); }
* catch (MetadataException e) { e.printStackTrace(); }
*/} catch (ImageReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
And this is the error log:
Description Resource Path Location Type
ImageReadException cannot be resolved to a type Viewer.java /Main/src/com/owleyes/moustache line 687 Java Problem
ExifTagConstants cannot be resolved to a variable Viewer.java /Main/src/com/owleyes/moustache line 666 Java Problem
TiffImageMetadata cannot be resolved to a type Viewer.java /Main/src/com/owleyes/moustache line 660 Java Problem
Sanselan cannot be resolved Viewer.java /Main/src/com/owleyes/moustache line 659 Java Problem
JpegImageMetadata cannot be resolved to a type Viewer.java /Main/src/com/owleyes/moustache line 659 Java Problem
JpegImageMetadata cannot be resolved to a type Viewer.java /Main/src/com/owleyes/moustache line 659 Java Problem
The import org.apache.sanselan cannot be resolved Viewer.java /Main/src/com/owleyes/moustache line 11 Java Problem
The import org.apache.sanselan cannot be resolved Viewer.java /Main/src/com/owleyes/moustache line 10 Java Problem
The import org.apache.sanselan cannot be resolved Viewer.java /Main/src/com/owleyes/moustache line 9 Java Problem
The import org.apache.sanselan cannot be resolved Viewer.java /Main/src/com/owleyes/moustache line 8 Java Problem
The import org.apache.sanselan cannot be resolved Viewer.java /Main/src/com/owleyes/moustache line 7 Java Problem
Clearly you don’t have the needed library: Apache Sanselan.
Download the binaries here: http://commons.apache.org/imaging/download_sanselan.cgi, and extract the archive. Put the
sanselan-{version}.jarin your project’slibsdirectory. Recompile, and the errors should be gone.Remember – Android doesn’t have Sanselan library included out of the box.