java - 找不到符号类 "Builder"

标签 java android android-studio

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

我创建了一个新项目,有一个登录 Activity ,但 Activity 似乎有错误:![在此处输入图片描述][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();
    }

最佳答案

它是 Unable to build PlusClient 的副本和 can not find symbol class Builder

快速引用: 问题是 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即,不是创建 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();      
    

关于java - 找不到符号类 "Builder",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27668569/

相关文章:

android - R8 将抽象类的 "protected"方法更改为 "public"而没有 -allowaccessmodification 标志

java - Chrome 不断在新选项卡中打开 pdf 文件

java - Matlab 和 Java 集成

android - 未找到 Google Play 显着披露

android - 在 RecyclerView 下方放置一个 View

android - 如何根据文件类型打开合适的应用程序

java - 用于访问 Azure Data Lake 的客户端 ID、身份验证 token 端点、客户端 key 是什么?

java - 写入字节数组时出现 IOException

android-studio - Android Studio 0.8.1 - 如何使用 Facebook SDK?

android - 如何在 Android Studio 编写的项目中使用自定义字体