2013-06-12 51 views
2

我的地圖不會顯示。我甚至不知道Log Cat中的地圖網格或任何錯誤消息。我沒有得到任何類型的「通過谷歌API無法驗證」或類似的東西(這讓我相信我的API密鑰是正確的)。我根本沒有得到任何類型的地圖。谷歌地圖沒有空的瓷磚,沒有地圖,沒有LogCat錯誤。地圖API V2 6/2013

配置&清單

  1. 我使用的是Android模擬器(我retrived調試鍵來生成我的API密鑰,因爲我不是出口以此爲APK)
  2. 我適當地得到了jdk1的SHA1。 7和調試密鑰庫
  3. 我同時啓用Google地圖V2和GooglMapsAndroidV2 API開發人員控制檯上
  4. 我啓用所有必需的和推薦作爲在我的清單如下所示的權限,元數據和特徵(如OpenGL 2)
  5. 我已啓用Android PrivateLibraries a。 Google-play-services.jar b。 Android-support-v4.jar
  6. 我有Android依賴項: a。谷歌播放,services_lib.jar
  7. 我已經coppied我project.properties和proguard的文件在這個崗位的底部

enter image description here

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

    <uses-sdk 
     android:minSdkVersion="9" 
     android:targetSdkVersion="17" /> 

    <permission 
     android:name="com.example.mapdemo.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature"/> 

    <uses-permission android:name="com.example.proximitystuff.permission.MAPS_RECEIVE"/> 

    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> 
    <!-- The following two permissions are not required to use 
     Google Maps Android API v2, but are recommended. --> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

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

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme"> 

     <uses-library 
      android:name="com.google.android.maps"/> 
     <activity 
      android:name="com.example.proximitystuff.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> 

     <activity 
      android:name="com.example.proximitystuff.MyMapActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAPACTIVITY" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 

     <service 
      android:name="com.example.proximitystuff.ProxyBackgroundCheck" 
      android:enabled="true" 
      android:permission="com.example.ADAMS_PROX_PERMISSION" > 
     </service> 

     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="AIzaSyBnQNgn166qfatch_xcFwL8K0AfVHBYcGA"/> 

    </application> 

</manifest> 

Java代碼和XML佈局: 我的主要活動使用按鈕進入屏幕截圖中顯示的地圖活動。這個地圖活動的代碼被規定爲最基本的功能,它仍然不會工作。我所理解的一個理論是,由於這個類沒有從「FragmentActivity」繼承,所以它能夠使用xml片段(我希望如果是這種情況,我會在日誌中至少得到某種類型的錯誤)。

package com.example.proximitystuff; 


import android.app.Activity; 
import android.os.Bundle; 


public class MyMapActivity extends Activity { 


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

My XML layout is using the most basic layout possible. 
<?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" 
      android:name="com.google.android.gms.maps.MapFragment"/> 

enter image description here

Project.properties

# This file is automatically generated by Android Tools. 
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! 
# 
# This file must be checked in Version Control Systems. 
# 
# To customize properties used by the Ant build system edit 
# "ant.properties", and override values to adapt the script to your 
# project structure. 
# 
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 

# Project target. 
target=android-17 
android.library.reference.1=../google-play-services_lib 

Proguard的(以防萬一這是錯誤的):

# To enable ProGuard in your project, edit project.properties 
# to define the proguard.config property as described in that file. 
# 
# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in ${sdk.dir}/tools/proguard/proguard-android.txt 
# You can edit the include path and order by changing the ProGuard 
# include property in project.properties. 
# 
# For more details, see 
# http://developer.android.com/guide/developing/tools/proguard.html 

# Add any project specific keep options here: 

# If your project uses WebView with JS, uncomment the following 
# and specify the fully qualified class name to the JavaScript interface 
# class: 
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { 
# public *; 
#} 
-keep class * extends java.util.ListResourceBundle { 

protected Object[][] getContents(); 

} 

回答

1

發現問題。顯然我是一個白癡,並有:

2 api鍵註冊到相同的SHA1和相同的包名稱...基本上我兩次註冊API訪問應用程序(在API控制檯上),並隨意爲我的清單選擇其中一個API鍵(顯然,Big「no no」)。

因此,每個地圖只有一個API密鑰,否則您的應用程序無法正常工作,並且沒有任何日誌錯誤。你也不會看到任何瓷磚(空或不)。感謝您的幫助,希望這可以爲我節省一些嘗試和錯誤的時間。

2

我使用的是Android模擬器

AFAIk,Android模擬器不支持Maps V2或涉及Play服務的任何內容。雖然他們宣佈了一個解決方案,但我不知道已經發布了更新的圖像。

+0

哇!這聽起來令人難以置信的不便...你在哪裏看到這個文件(我很驚訝,我沒有找到它)?我似乎記得模擬器API版本1完美工作。 另一個說明:當我創建一個發佈apk並運行在我的pantech flex(Running ICS)上。我似乎得到空瓷磚(我註冊了我的發行版SHA1,以便使用調試代替新的API密鑰)。你是否看到我的帖子中有任何問題可能是這個原因? 非常感謝你,有幸擁有像你這樣的專家花時間回答這個問題。 –

+0

@adamkim:「我似乎記得模擬器完美地與API版本1一起工作」 - Maps V1和Maps V2在模擬器支持方面沒有關係。 「你看到我的帖子中有什麼問題可能是這個原因嗎?」 - 你的''('com.example.mapdemo.permission.MAPS_RECEIVE')與相應的''('com.example.proximitystuff.permission.MAPS_RECEIVE')不匹配,這可能會解釋它。 – CommonsWare

+0

感謝您的支持!我複製並粘貼了那些代碼,希望我有一個原本錯過的錯字(看起來像是發生了故障)。不幸的是,問題依然存在。儘管我說錯了,但它不是「空瓷磚問題」,更多的是沒有瓷磚,也沒有背景問題。我會繼續尋找,雖然我不知道還有什麼可以尋找 –