2014-12-27 143 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();