2014-03-14 120 views
1

我試圖在我的模擬器上顯示谷歌地圖內的孩子片段。但問題是,模擬器凍結一起舉杯,而地圖加載這樣的連續顯示:谷歌地圖V2加載灰色屏幕掛起

enter image description here

我檢查我的清單文件,重新創建API密鑰和debug.keystore兩者。但仍然無法正常工作。請告訴我如何解決這個問題。謝謝。

**注:**我正在Genymotion仿真器 - Galaxy S2 API 10(2.3.7)上測試。 Google Play服務已安裝在模擬器上。

的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.estytic.clubinthechi" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="18" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="com.example.project.permission.MAPS_RECEIVE"/> 

    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true" /> 

    <permission 
     android:name="com.example.project.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 
    <uses-permission android:name="android.permission.CALL_PHONE"/> 

    <application 
     android:hardwareAccelerated="false" 
     android:logo="@drawable/ic_drawer1" 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <meta-data android:name="com.google.android.maps.v2.API_KEY" 
android:value="api-key"/> 

     <uses-library android:name="com.google.android.maps" /> 
     <activity 
      android:name="com.example.project.MainActivity" 
      android:label="@string/app_name" 
      android:clearTaskOnLaunch="true" 
android:stateNotNeeded="true" 
android:theme="@style/Theme.AppCompat" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

MapFragment.java

public class MapFragmentClass extends Fragment implements GooglePlayServicesClient.ConnectionCallbacks,GooglePlayServicesClient.OnConnectionFailedListener,LocationListener { 

    //to extract current loc 
    private LocationClient locationclient; 
    private LocationRequest locationrequest; 
    SupportMapFragment mapFragment; 
    GoogleMap map; 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     View view = inflater.inflate(R.layout.map_fragment, null); 
     return view; 
    } 

    @Override 
    public void onViewCreated(View view, Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onViewCreated(view, savedInstanceState); 

      FragmentManager fm = getChildFragmentManager(); 
      mapFragment = (SupportMapFragment) fm.findFragmentById(R.id.map); 
      if (mapFragment == null) { 
       mapFragment = SupportMapFragment.newInstance(); 
       fm.beginTransaction().replace(R.id.map, mapFragment).commit(); 
       fm.executePendingTransactions(); 

       delayMapLoading(); 

      } 

    } 

    void delayMapLoading() 
    { 
     Handler handler = new Handler(); 
     handler.postDelayed(new Runnable() 
     { 
      @Override 
      public void run() { 
       map = mapFragment.getMap(); 

       if(map != null) 
       { 
        Log.i("MSG","map is not null"); 
        map.setMyLocationEnabled(true); 
       map.setMapType(GoogleMap.MAP_TYPE_SATELLITE); 

       } 

       else { 
        // handler.postDelayed(this, 500); 
       } 
      } 
      }, 1000); 

    } 

map_fragment.xml

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" > 
<FrameLayout android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1.03" 
    android:name="com.google.android.gms.maps.SupportMapFragment" /> 

</LinearLayout> 

回答

0

如果您創建debug.keystore,那麼您是否使用這個相同的密鑰庫路徑導出應用程序?

我想你沒有導出你的應用程序..

Please export your app with same keystore which is created .. 

我希望你解決你的問題。

+0

我不明白。通過導出具有相同密鑰庫路徑的應用程序,你的意思是什麼?你能詳細說明嗎? – NightFury

+1

請創建密鑰存儲並將其用於導出應用。 右鍵單擊proejct-> export - > ..... – dipali

+0

好的。我會在10-12個小時後檢查並通知你。 – NightFury

0

更改map_fragment.xml

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" > 
<FrameLayout android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1.03" 
    android:name="com.google.android.gms.maps.SupportMapFragment" /> 

</LinearLayout> 

<?xml version="1.0" encoding="utf-8"?> 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:map="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center" 
     android:orientation="vertical" > 

    <fragment android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1.03" 
     android:name="com.google.android.gms.maps.SupportMapFragment" /> 

    </LinearLayout> 
+0

謝謝你的回覆。我現在無法檢查。半天后會通知你。 – NightFury

+0

肯定, 沒問題! – Namy

+0

我剛試過。它沒有工作 – NightFury