2015-01-04 76 views
0

創建新項目,並選擇最小的SDK 2.3.3薑餅然後選擇谷歌地圖的活動。 android studio的默認準備工作。在以上و但在API 10 API 11這個項目的工作(例如銀河ŸS5360,沒有安裝谷歌播放服務)的消息顯示「谷歌得到發揮服務」。例如,我在這個版本中運行的應用程序和這個設備(S5360),谷歌地圖的工作沒有任何問題。 請幫忙(對不起,我的英語)的Android 1.0.1工作室谷歌地圖v2的不工作的API 10

我的build.gradle是:

android { 
compileSdkVersion 21 
buildToolsVersion "21.1.2" 

defaultConfig { 
    applicationId "com.example.ehm.tantum" 
    minSdkVersion 10 
    targetSdkVersion 21 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.android.support:appcompat-v7:21.0.3' 
compile 'com.google.android.gms:play-services:6.5.87' 
compile 'com.android.support:support-v4:21.0.3' } 

我mainfest是:

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

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

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

<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.gms.version" 
     android:value="@integer/google_play_services_version" /> 
    <meta-data 
     android:name="com.google.android.maps.v2.API_KEY" 
     android:value="@string/google_maps_key" /> // i have API key this prject 

    <activity 
     android:name=".MapsActivity" 
     android:label="@string/title_activity_maps" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

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

我mapActivity:

public class MapsActivity extends FragmentActivity { 

private GoogleMap mMap; // Might be null if Google Play services APK is not available. 

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

@Override 
protected void onResume() { 
    super.onResume(); 
    setUpMapIfNeeded(); 
} 

private void setUpMapIfNeeded() { 
    // Do a null check to confirm that we have not already instantiated the map. 
    if (mMap == null) { 
     // Try to obtain the map from the SupportMapFragment. 
     mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) 
       .getMap(); 
     // Check if we were successful in obtaining the map. 
     if (mMap != null) { 
      setUpMap(); 
     } 
    } 
} 


private void setUpMap() { 
    mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker")); 
} 

我的libs文件夾默認爲空。

請大家幫忙。

回答

0

如果您還沒有您的設備上安裝谷歌播放服務,地圖行不通。 您需要使用與編譯應用程序相同的版本(6.5.87根據您的構建文件)

其他應用程序正在工作的事實意味着(或者我認爲至少)是因爲您擁有過時的版本播放服務和其他應用程序與舊版本的播放服務一起編譯。

嘗試將您的設備

上更新服務