2010-02-06 67 views
0

我正在使用IntelliJ IDEA 9(9.0.1)創建一個簡單的地圖應用程序(或至少嘗試)。 我在Google API 2.0中使用Android 2.0。Android 2.0 SDK地圖不顯示

清單:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
      package="com.example"> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".MyActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 
       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 
     <activity android:name=".disaster"/> 
     <activity android:name=".map" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"/> 
     <uses-library android:name="com.google.android.maps" /> 
    </application> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
</manifest> 

類:

​​

查看:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/map" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/wall" 
    > 
     <View android:id="@+id/mv" 
     class="com.google.android.maps.MapView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:enabled="true" 
     android:apiKey="08zxVQUd22SOeAuv8AEMS5hBAeOdll4OzDrNYpQ"/> 

     <Button android:id="@+id/backBtn" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:text="@string/backBtn"/> 

</LinearLayout> 

這只是給了我一個空白屏幕。

我在做什麼錯了?

編輯:澄清我的OP。

回答

0

確保您有權限去到互聯網,並訪問您的AndroidManifest.xml地點:

<uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

編輯:

好吧,似乎情況是敏感的,從這樣改變:

<View android:id="@+id/mv" 

<view android:id="@+id/mv" 

應顯示您的地圖。

+0

你好,謝謝你的思考。 我已經設置了android.permission.INTERNET,現在即使只顯示地圖也不行,更不用說使用手機的GPS位置了。所以我第一次試圖讓前者工作。 – user211992 2010-02-06 18:16:52

+0

你可以更新你的OP與您的活動,也許你的地圖xml的完整佈局? 你也需要在你的mapview中設置一個id(你給的com.google.android.maps.MapView例子沒有,你需要從你的活動中引用它) – ccheneson 2010-02-06 18:39:34

+0

我已經更新了我的開始帖子,希望現在更清楚。 地圖是我從應用程序菜單調用的視圖。(以及我打電話給開始視圖的地圖類) – user211992 2010-02-06 20:08:42

1

您必須包含Maps API調試密鑰才能顯示地圖內容。 http://code.google.com/android/add-ons/google-apis/maps-overview.html

+0

我正在使用我發佈的第二個代碼,並填寫了一個密鑰。 我剛剛用myKey替換它以保證安全。 我可能應該提到這一點。 – user211992 2010-02-06 11:35:55

+0

我自己並沒有簽署應用程序,但根據http://developer.android.com/intl/zh-TW/guide/developing/other-ide.html#DebugMode應該自動發生。 有沒有辦法檢查這是否真的發生了? – user211992 2010-02-06 11:55:22

+0

'jarsigner -verify -verbose my_application.apk'會告訴你,如果你的應用程序已簽署 – emmby 2010-04-20 22:43:49

0

好吧,如果IDEAJ比它取決於該Android插件調試密鑰簽名是否發生automatically..check插件文檔與您的構建文件一起,你可能需要添加一個調試鍵登錄目標

0

時可能你導出你的apk文件,確保你用相同的api鍵導出它,否則你將只有地圖的網格線。 debug.keystore的密碼是android,然後選擇別名,然後導出。這是您需要將其導出爲實際的手機時!