2014-12-27 310 views
2

我最近下載了Android Studio,我以爲它有比eclipse更多的功能。找不到符號類「Builder」

我創建了一個新的項目,以日誌的活動,但似乎有一個與活動的錯誤:[在這裏輸入的形象描述] [1]

**Error:(78, 31) error: cannot find symbol class Builder 
Error:Execution failed for task ':app:compileDebugJava'. 
> Compilation failed; see the compiler error output for details.** 

import com.google.android.gms.plus.PlusClient; 
 

 

 
    // This is the helper object that connects to Google Play Services. 
 
    private PlusClient mPlusClient; 
 

 

 
@Override 
 
    protected void onCreate(Bundle savedInstanceState) { 
 
     super.onCreate(savedInstanceState); 
 

 
     // Initialize the PlusClient connection. 
 
     // Scopes indicate the information about the user your application will be able to access. 
 
     mPlusClient = 
 
       new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN, 
 
         Scopes.PLUS_ME).build(); 
 
    }

+0

可能類似的問題是[這裏](http://stackoverflow.com/questions/15108235/unable-to-build-plusclient ) – SMA 2014-12-27 15:22:27

回答

-1

我認爲您還沒有下載Google Play服務,如果是的話,請從SDK Manager - > Extras - > Google Play Services下載它們。

,以及它們是否已經下載,那麼你應該做的

第5步Google+ Quickstart:

  • 導入谷歌Play服務庫項目。
  • 選擇文件>導入> Android>現有的Android代碼進入工作區,然後單擊下一步。 選擇瀏覽....輸入/ extras/google/google_play_services /。 選擇google-play-services_lib。點擊完成導入。

    希望它能幫助你。

    +0

    當我們在Android Studio中使用模板時,他們添加了play-services作爲依賴項,如果他們甚至沒有,那麼我們不需要導入播放服務。我們只需要在''build.gradle''中添加compile語句,例如''com.google.android.gms:play-services:6.5.87''.Can you please explain your answer? – 2015-01-11 11:53:32

    8

    這是Unable to build PlusClientcan not find symbol class Builder

    重複爲快速參考: 的問題是,PlayClient現在已經過時,但仍然模板使用的老辦法。

    因此,您可以:

    1. 變化的gradle這個依賴(build.gradle)播放服務版本從com.google.android.gms:play-services:6.5.87com.google.android.gms:play-services:6.1.71

    OR

      這裏描述
    1. 使用新的方法:http://android-developers.blogspot.in/2014/02/new-client-api-model-in-google-play.html即,而不是創建的PlusClient.Builder實例如圖創建的GoogleApiClient.Builder一個實例:

      // Builds single client object that connects to Drive and Google+ 
      
      import com.google.android.gms.common.api.GoogleApiClient; 
      mClient = new GoogleApiClient.Builder(this) 
           .addApi(Drive.API) 
           .addScope(Drive.SCOPE_FILE) 
           .addApi(Plus.API, plusOptions) 
           .addScope(Plus.SCOPE_PLUS_LOGIN) 
           .addConnectionCallbacks(this) 
           .addOnConnectionFailedListener(this) 
           .build();