找不到符号类"Builder"

HT2*_*2k9 3 java android android-studio

我最近下载了Android Studio,我认为它有更多功能eclipse.

我创建了一个具有登录活动的新项目,但似乎活动出现错误:![在此处输入图像描述] [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.**
Run Code Online (Sandbox Code Playgroud)

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();
    }
Run Code Online (Sandbox Code Playgroud)

sah*_*wat 8

这是一个重复无法建立PlusClient不能找到符号类生成器

对于快速参考:问题是PlayClient现在已弃用,但模板仍使用旧方法.

因此,您可以:

  1. 将gradle依赖项(build.gradle)中的播放服务版本从com.google.android.gms:play-services:6.5.87 更改为 com.google.android.gms:play-services:6.1.71.

要么

  1. 使用此处描述的新方法:http://android-developers.blogspot.in/2014/02/new-client-api-model-in-google-play.html ie,而不是创建创建实例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();      
    
    Run Code Online (Sandbox Code Playgroud)