2015-12-22 51 views
1

我在Andriod的工作室開發,與我創建像這樣GoogleApiClient的一個實例:無法連接到GoogleApiClient因錯誤代碼:SERVICE_VERSION_UPDATE_REQUIRED

locationClient = new GoogleApiClient.Builder(this) 
       .addConnectionCallbacks(this) 
       .addOnConnectionFailedListener(this) 
       .addApi(LocationServices.API) 
       .build(); 

我有一個onConnectionFailed處理程序是這樣的:

@Override 
public void onConnectionFailed(ConnectionResult connectionResult) { 
    if (connectionResult.hasResolution()) { 
     try { 
      connectionResult.startResolutionForResult(ACTRequest.this, 6); 
     } catch (IntentSender.SendIntentException e) { 
     } 
    } else { 
     //Connection failure cannot be resolved 
     Toast.makeText(getApplicationContext(), 
       "Unable to connect to Google Service, sorry >_<" + connectionResult.getErrorMessage(), Toast.LENGTH_LONG) 
       .show(); 
     Log.d("CONNECTION FAIL", connectionResult.getErrorCode() + " Unable to connect to Google Service, sorry >_<"); 
    } 
} 

每次執行此活動,我都會收到錯誤代碼:2 = SERVICE_VERSION_UPDATE_REQUIRED

要解決此問題,我安裝了Google Play Service revisi在android studio上29.0.0,我確信我的模擬器有API23。不過,我仍然收到這個錯誤。

我不知道該怎麼辦,我怎麼能更新我的模擬器上的谷歌播放服務?我的代碼有問題嗎?

解決方法:

感謝暗示2.0模擬器!這是我發現解決(排序)這個問題的另一種方式:

由於在模擬器上更新谷歌播放服務非常困難,我們可以在谷歌服務的gradle依賴項中將版本降低到1.5

dependencies { 
    classpath 'com.android.tools.build:gradle:1.3.1' 
    classpath 'com.google.gms:google-services:1.5.0-beta1' 
} 

及用途::

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

這不但是建議,當我們構建項目的3.0β1的。

回答

0

得到這個工作與仿真器,在預覽使用新的仿真器2.0版目前:http://tools.android.com/tech-docs/emulator

+0

非常感謝您! – user3685578

+0

如果這可以幫助您,請將其標記爲已接受的答案,這樣可以幫助其他人使用相同的問題 –

+0

如何升級到v2.0? – feresr

相關問題