1

現狀:問題還沒有解決YET-需要幫助..谷歌地圖API的Android -N 2錯誤我的Android應用程序

林現在使用新的谷歌地圖的Android V2開發地圖應用程序..之前,我將它應用到我的真實應用程序..我做了測試..並試圖使其工作..我跟着documentation由谷歌開發商

但似乎有一些我錯過了一部分,但無法找到它們你能爲我識別他們嗎?我預訂購作罷我的源代碼如下......讓你看到他們清楚..

這裏我目前MainActivity類別(更新):< ---我只有這個類在我的計劃

package com.madcatworld.demomapv2; 

    import com.google.android.gms.maps.SupportMapFragment; 

    import android.os.Bundle; 
    import android.support.v4.app.FragmentActivity; 
    import android.view.Menu; 

    public class MainActivity extends FragmentActivity { 

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

     SupportMapFragment fragment = new SupportMapFragment(); 
     getSupportFragmentManager().beginTransaction() 
       .add(R.id.map, fragment).commit(); 

     } 

     @Override 
     public boolean onCreateOptionsMenu(Menu menu) { 
      // Inflate the menu; this adds items to the action bar if it is present. 
      getMenuInflater().inflate(R.menu.activity_main, menu); 
      return true; 
     } 

    } 

這裏是我的activity_main.xml中:(更新)

<?xml version="1.0" encoding="utf-8"?> 
<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    class="com.google.android.gms.maps.SupportMapFragment" /> 

這裏是我的Manifest.xml:

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

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

     <uses-sdk 
      android:minSdkVersion="8" 
      android:targetSdkVersion="14" /> 

     <permission 
      android:name="com.madcatworld.demomapv2.permission.MAPS_RECEIVE" 
      android:protectionLevel="signature" /> 

     <uses-permission android:name="com.madcatworld.demomapv2.permission.MAPS_RECEIVE" /> 
     <uses-permission android:name="android.permission.INTERNET" /> 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
     <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 

     <application 
      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="xxxxxxxxxxxxxxx" /> 

      <activity 
       android:name="com.madcatworld.demomapv2.MainActivity" 
       android:label="@string/app_name" > 
       <intent-filter> 
        <action android:name="android.intent.action.MAIN" /> 

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

    </manifest> 

我的模擬器:對話框「Get Google Play Services」出現..當我點擊它時...下面會出現一些錯誤..

我的當前錯誤日誌(更新)它似乎比以前的錯誤更短! :):

01-25 04:23:18.647: E/AndroidRuntime(503): FATAL EXCEPTION: main 
01-25 04:23:18.647: E/AndroidRuntime(503): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://play.google.com/store/apps/details?id=com.google.android.gms flg=0x80000 pkg=com.android.vending } 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Activity.startActivityForResult(Activity.java:2817) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Activity.startActivity(Activity.java:2923) 
01-25 04:23:18.647: E/AndroidRuntime(503): at com.google.android.gms.internal.d$2.onClick(Unknown Source) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.view.View.performClick(View.java:2408) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.view.View$PerformClick.run(View.java:8816) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.os.Handler.handleCallback(Handler.java:587) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.os.Handler.dispatchMessage(Handler.java:92) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.os.Looper.loop(Looper.java:123) 
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.ActivityThread.main(ActivityThread.java:4627) 
01-25 04:23:18.647: E/AndroidRuntime(503): at java.lang.reflect.Method.invokeNative(Native Method) 
01-25 04:23:18.647: E/AndroidRuntime(503): at java.lang.reflect.Method.invoke(Method.java:521) 
01-25 04:23:18.647: E/AndroidRuntime(503): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
01-25 04:23:18.647: E/AndroidRuntime(503): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
01-25 04:23:18.647: E/AndroidRuntime(503): at dalvik.system.NativeStart.main(Native Method) 

爲了您的信息,

  1. 我已經生成我的谷歌帳戶從日食複製我 SHAI NUM新的API密鑰..

  2. 我這樣做步驟Android的工具>右鍵>導出簽名 應用程序包(使它們相互鏈接,我創建新的 密鑰庫)我的問題是:我應該實現這個(不是2)?

請讓我知道如果u發現我已經犯任何錯誤。謝謝

回答

0

你犯了一個錯誤,你是在試圖訪問android.R.id.content凡在你的my activity_main.xml文件Mapfragment ID是android:id="@+id/map"

所以,試試這種方式。

把這個代碼在你的onCreate(..)方法

SupportMapFragment fragment = new SupportMapFragment(); 
    getSupportFragmentManager().beginTransaction() 
      .add(R.id.map, fragment).commit(); 

,而不是這個。

SupportMapFragment fragment = new SupportMapFragment(); 
     getSupportFragmentManager().beginTransaction() 
       .add(android.R.id.content, fragment).commit(); 
+0

謝謝迪克西特帕特爾:),已經改變了them..there仍然errors..i將更新我的錯誤日誌.. –

+0

把您的SupportMapFragment代碼 –

+0

我可以只顯示地圖,而不使用支持地圖片段Dixil Patel ??我在昨天瀏覽解決方案時執行該代碼..我將它們粘貼在那裏..類不存在.. –

0

而不是使用commit()使用.getMap();方法獲取並加載地圖。

GoogleMap mMap; 
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) 
       .getMap(); 
+0

謝謝Grishu .. :)已經改變了..將盡快更新最新的代碼和錯誤日誌.. Grishu。 ..我沒有SupportMapFragment類..我可以顯示地圖而不創建類?即使在我的MainActivity類中包含supportMapFragment命令? –

+0

請檢查我已更新我的回答。 – GrIsHu

+0

Grishu已經做了..我刪除了SupportMapFragement代碼並實現了urs ...似乎不工作.. Eclipse建議我刪除ur代碼.. :( –

相關問題