2014-09-23 135 views
3

我正試圖將Google Play服務庫實現到我的Android應用程序。但是有一個關於isGooglePlayServicesAvailable函數的問題。是GooglePlayServicesAvailable總是返回2

雖然我的播放服務是最新的,但它返回2,這意味着根據文檔SERVICE_VERSION_UPDATE_REQUIRED。

我的代碼如下:提前

@Override 
protected void onResume() { 
    super.onResume(); 
    int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(LoginSigninActivity.this); 
    if(statusCode != ConnectionResult.SUCCESS) 
    { 
     Log.e("statuscode",statusCode+""); 
     if(GooglePlayServicesUtil.isUserRecoverableError(statusCode)) 
     { 
      Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
        statusCode, 
        LoginSigninActivity.this, 
        REQUEST_CODE_RECOVER_PLAY_SERVICES); 

      // If Google Play services can provide an error dialog 
      if (errorDialog != null) { 
       errorDialog.show(); 
      } 
     } 
     else 
     { 
      Toast.makeText(this, getString(R.string.toast_google_play_services_not_found),Toast.LENGTH_LONG).show(); 
     } 
    } 
} 

感謝。

P.S.錯誤對話框始終顯示。

+0

你能告訴我們這個logcat錯誤嗎?這就像「需要XXXXX,但找到YYYYYY」? – 2014-09-23 07:55:18

回答

2

不,它不應該。

設備與安卓4.4.4有播放服務版本5.0.89其中與Android L預覽的設備已播放服務版本5.2.08。這就是爲什麼android工作室要求你更新你的播放服務版本到5.2.08。所以,現在使用

compile 'com.google.android.gms:play-services:5.0.89' 

如果你使用的是android L模擬器,我認爲你應該使用5.2.08。

如果你想更新你的播放服務到5.2看到this

+0

我的設備是Android 4.4.2,如果我按照錯誤對話框,我無法更新,因爲它已經是最新的。順便說一句,我正在使用compile'c​​om.google.android.gms:play-services:5. +' – SafaOrhan 2014-09-23 08:07:10

+0

請使用我給你的鏈接或使用5.0.89版本更新到5.2。 – 2014-09-23 08:11:08

+0

恐怕沒有鏈接。 – SafaOrhan 2014-09-23 08:11:47

0

我也面臨同樣的問題。我使用最新的播放服務版本:5. +開發可能的應用程序。但我的設備有Kitkat使用播放服務版本:4.4.52。它總是說SERVICE_VERSION_UPDATE_REQUIRED,因爲我構建了一個使用高版本播放服務但應用程序版本較低的應用程序。

我的建議是使用較低的播放服務版本來開發您的應用程序或使用高版本播放服務的設備。