2014-03-18 153 views
1

试图实现谷歌地图API在我的Android项目,并得到警告错误是在我的Java代码无法创建谷歌地图片段

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()); 

回答

0

你加

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

您的清单在应用程序标签下?

+0

是的,我做了...... – Quion

+0

03-19 08:58:50.250:I /编舞师(2443):跳过了42帧!应用程序可能在其主线程上做了太多工作。 – Quion

+0

越来越好了.... – Quion

2
  1. 运行`cmd`并生成一个新的“SHA1”键。
  2. 浏览至https://code.google.com/apis/console/?noredirect'API Console`页面。
  3. 用新的“sha1”键替换旧的“ShA1”。
  4. 然后替换你的新地图密钥。

你的问题解决了。我也有这个问题。 (我只改变了我的地图键)