I have published an application that contains maps api (google-play-services) and ActionBar Sherlock and I've made too many tests in too many devices, several versions.
But there was an user that downloaded the application ( https://play.google.com/store/apps/details?id=br.ufc.ondefica ) with his device (Galaxy Ace (GT-S5830B)) and when he went to the "Ver Mapa" (See map) menu on drawer, he had the following exception:
java.lang.NoSuchMethodError: java.io.IOException.<init>
at com.google.android.gms.internal.g.f(Unknown Source)
at com.google.android.gms.internal.g.b(Unknown Source)
at com.google.android.gms.internal.e.a(Unknown Source)
at com.google.android.gms.internal.e.a(Unknown Source)
at com.google.android.gms.internal.bq.ac(Unknown Source)
at com.google.android.gms.internal.cg$1.run(Unknown Source)
at com.google.android.gms.internal.ch$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
This is everything that Google Play shows me. So, I've looked for the error on Internet and I figured out that this error may happen because of the Maps App (but it's working perfectly, said the user) or it may there to be something to do with the IOException constructor that receives a Throwable like parameter (API level 9). I don't know where this error is, even because it's working on another devices with the same API Level than this device.
This is my MapFragment code:
public class UFCMapFragment extends FragmentWithSearch {
private GoogleMap map;
private int positionToShow = 3;
private boolean isDefaultView = true;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.map_layout, container, false);
((MainActivity) getActivity()).setTitle(getResources().getStringArray(R.array.sliding_menu)[0]);
return root;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
map.setMyLocationEnabled(true);
Bundle bundle = getArguments();
if (bundle != null && bundle.containsKey("positionToShow")) {
isDefaultView = false;
positionToShow = bundle.getInt("positionToShow");
}
loadMap();
// Move the camera instantly to the default place to show with a zoom of
// 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(DataHelper.data.places
.get(positionToShow).getCoordinates(), 13));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(16), 4000, null);
}
private void loadMap() {
for (int i = 0; i < DataHelper.data.places.size(); i++) {
Placemark place = DataHelper.data.places.get(i);
Marker marker = map.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(ParserKML
.loadMapOfIcons(place.getIconID())))
.title(place.getName()).snippet(place.getDescription())
.position(place.getCoordinates()));
if (i == positionToShow && !isDefaultView)
marker.showInfoWindow();
}
}
public void onDestroyView() {
super.onDestroyView();
Fragment fragment = (getFragmentManager().findFragmentById(R.id.map));
FragmentTransaction ft = getActivity().getSupportFragmentManager()
.beginTransaction();
ft.remove(fragment);
ft.commit();
}
}
Thanks in advance,
Cross-posted from:
The first line on the stracktrace gives you a clue:
java.lang.NoSuchMethodError: java.io.IOException.<init>
Basically it's saying that some constructor for IOException
is missing. Looking at the javadocs, there are two constructors that were added in API level 9:
public IOException (Throwable cause)
public IOException (String message, Throwable cause)
That should answer your question. API level 9 is Android 2.3. Hence, the stack trace is from a device running Android 2.2 or below, which is missing the two constructors above.
There are at least two solutions to solve the problem:
minSdkVersion
in your app's manifest to 9
.The latter you can find in the SDK Manager. It was added with the last update because support for Froyo (Android 2.2) was dropped. Quote from the linked blog post:
With over 97% of devices now running Android 2.3 (Gingerbread) or newer platform versions, we’re dropping support for Froyo from this release of the Google Play services SDK in order to make it possible to offer more powerful APIs in the future. That means you will not be able to utilize these new APIs on devices running Android 2.2 (Froyo).