2013-12-14 43 views
0

我正在嘗試在android 2.3上顯示谷歌地圖。 我跟着從here在真實的Android 2.3設備上顯示GoogleMap空白

的步驟我採用了android 0.3.7工作室 我得到類似圖像this

MainActivity.java:

package com.Greek.Market; 
import android.support.v4.app.FragmentActivity; 
import android.support.v4.app.Fragment; 
import android.os.Bundle; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.SupportMapFragment; 
public class MainActivity extends FragmentActivity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
    } 
} 

activity_main.xml中:

<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=".MainActivity" > 

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

清單:

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

    <uses-sdk 
     android:minSdkVersion="10" 
     android:targetSdkVersion="19" /> 

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

     <meta-data android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 

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

     <activity 
      android:name="com.Greek.Market.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> 


    <permission 
     android:name="com.Greek.Market.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature"/> 
    <uses-permission android:name="com.Greek.Market.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature"/> 

    <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"/> 

</manifest> 

build.grandle:

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.6.+' 
    } 
} 
apply plugin: 'android' 

repositories { 
    mavenCentral() 
} 

android { 
    compileSdkVersion 19 
    buildToolsVersion "19.0.0" 

    defaultConfig { 
     minSdkVersion 10 
     targetSdkVersion 19 
    } 
    buildTypes { 
     release { 
      runProguard false 
      proguardFile getDefaultProguardFile('proguard-android.txt') 
     } 
    } 
    productFlavors { 
     defaultFlavor { 
      proguardFile 'proguard-rules.txt' 
     } 
    } 
} 

dependencies { 
    compile 'com.android.support:appcompat-v7:+' 
    compile 'com.google.android.gms:play-services:4.0.30' 
} 

我部署我的應用程序的是Android設備直接

上從我讀,我覺得問題是api_key,但我不知道在哪裏...

我得到SHA1使用以下命令: C:\ Program Files文件\的Java \ jdk1.6.0_21 \ BIN>的keytool -list -v -keystore 「C:\用戶\用戶\ .android \ debug.keystore」 -alias androiddebugkey -storepass android -keypass android

有人能幫助我嗎?我堅持

回答

0

幾件事情:

android:name="com.google.android.gms.maps.SupportMapFragment" 

2.從代碼,我還沒有看到的東西,你的其他部分:

從XML佈局文件刪除此行錯誤,所以你可以做的事情很少:

  • 使用API Console重現您的密鑰,你可以按照這篇博客文章,並確保你做的每一件事是正確的:Google Maps API V2 Key,確保兩次,你打開右邊API for Android
  • 如果你做了所有這些,並且仍然看到此問題,請確保從電話中刪除完整的應用程序,然後重新安裝此應用程序,直到您移除應用程序爲止,緩存API密鑰。
+0

終於工作了!問題是api_key。我創建了一個新的,從手機中刪除我的應用程序,它工作! 非常感謝 – user3102153

+0

歡迎@ user3102153:) –

相關問題