简体   繁体   中英

Unable to create Google map fragment

Trying to implement google map API in my android project and getting the warning error that is under my java code

GoogleMap gMap;

gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

LatLng Jamaica = new LatLng(18.1155173, -77.2760026);

gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(Jamaica, 13));

gMap.addMarker(new MarkerOptions()
    .title("Jamaica")
    .snippet("The greatest country in the world")
    .position(Jamaica));
gMap.setMyLocationEnabled(true);

Logcat:

03-18 12:45:00.140: W/ActivityThread(10477): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
  1. Run `cmd` and genereate a new "SHA1" key.
  2. Browse to https://code.google.com/apis/console/?noredirect `API Console` page.
  3. Replace the old "ShA1" with the new "sha1" key.
  4. Then replace your new map key.

Your problem solved. I also had this problem. (I only changed my map key)

Did you add

<uses-library android:name="com.google.android.maps" />

to your manifest under the application tag?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM