2014-07-16 26 views
0

我正在爲必須添加地圖的應用程序工作。並在地圖上顯示當前用戶的位置。在Android中使用地圖時獲取dalvikvm的logcat?

我收到下面的錯誤。雖然地圖是顯示,但當前用戶位置沒有顯示

Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence', referenced from method glt.a 

這不是工作

googleMap.setMyLocationEnabled(true); 
+0

獲得了新的api密鑰,嘗試創建新的api密鑰.... –

回答

0

我告訴你我是如何解決你有同樣的問題。

首先,我清理了所有的sdk,然後我再次下載了Google Play Services lib。然後,我刪除了我的電腦的.android文件夾,並重新生成了我的debug.keystore。

之後,我只是讓我的新SHA1獲得我的Google Maps V2 Api密鑰。

更新我的apikey後,讓我們看看如何更改我的代碼。

現在我在你的xml佈局中使用MapFragment的MapFragment片段。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MapsActivity" > 

<fragment 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    class="com.google.android.gms.maps.MapFragment" /> 

並使用FragmentManager找到它:

public class MapsActivity extends Activity 

{

private GoogleMap map; 

@Override 
protected void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_map); 

    // Gets the MapView from the XML layout and creates it 
    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); 
    map.getUiSettings().setMyLocationButtonEnabled(false); 
    //map.setMyLocationEnabled(true); 
    map.setOnMapClickListener(this); 
    map.setOnMapLongClickListener(this); 
    try 
    { 
     MapsInitializer.initialize(MapsActivity.this); 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
    } 
} 

我希望這是有幫助和抱歉,如果我的英語是如此糟糕, 問候

+0

獲得了新的api密鑰,嘗試創建新的api密鑰.... –