【问题标题】:cannot find symbol class "Builder"找不到符号类“Builder”
【发布时间】:2015-02-25 13:29:27
【问题描述】:

我最近下载了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.**

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();
    }

【问题讨论】:

  • 可能类似的问题是here

标签: java android android-studio


【解决方案1】:

它与Unable to build PlusClientcan 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();      
    

【讨论】:

    【解决方案2】:

    我认为您还没有下载 Google Play 服务,如果是,请从 SDK Manager -> Extras -> Google Play Services 下载它们。

    如果它们已经下载,那么你应该这样做

    Google+ Quickstart: 的第 5 步

    1. 导入 Google Play 服务库项目。

    选择 File > Import > Android > Existing Android Code Into Workspace,然后单击 Next。 选择浏览...。输入 /extras/google/google_play_services/。 选择 google-play-services_lib。点击完成导入。

    希望对你有所帮助。

    【讨论】:

    • 当我们在 Android Studio 中使用模板时,它们会添加 play-services 作为依赖项,如果它们不添加,我们就不需要导入 play 服务。我们只需要在build.gradle 中添加编译语句,例如com.google.android.gms:play-services:6.5.87.你能解释一下你的答案吗?
    猜你喜欢
    • 2017-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-28
    • 2018-09-28
    • 2019-03-24
    • 2015-03-21
    • 2018-08-09
    相关资源
    最近更新 更多