I'm having the issue that Android 10 can't read GPS information from my jpeg files. The exact same files are working on Android 9. I tried the ExifInterface (androidx) which returns null, as well as apache commons imaging which is saying "GPSLatitude: Invalid rational (0/0), Invalid rational (0/0)". Other exif information like the rating or XPKeywords are read correctly.
How to fix that?
Test code:
import androidx.exifinterface.media.ExifInterface;
ExifInterface exif2 = new ExifInterface(is);
double[] latLngArray = exif2.getLatLong();
getLatLong Implementation:
public double[] getLatLong() {
String latValue = getAttribute(TAG_GPS_LATITUDE);
String latRef = getAttribute(TAG_GPS_LATITUDE_REF);
String lngValue = getAttribute(TAG_GPS_LONGITUDE);
String lngRef = getAttribute(TAG_GPS_LONGITUDE_REF);
if (latValue != null && latRef != null && lngValue != null && lngRef != null) {
try {
double latitude = convertRationalLatLonToDouble(latValue, latRef);
double longitude = convertRationalLatLonToDouble(lngValue, lngRef);
return new double[] {latitude, longitude};
} catch (IllegalArgumentException e) {
Log.w(TAG, "Latitude/longitude values are not parseable. " +
String.format("latValue=%s, latRef=%s, lngValue=%s, lngRef=%s",
latValue, latRef, lngValue, lngRef));
}
}
return null;
}
All getAttribute calls are returning null on Android Q/10. On Android 9 it is working. My test photo does contain GPS information. Even Android itself was unable to index the GPS location into their media store. The field is null as well in their database. I transferred the test photo via mail.