我最近下载了 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 现在已被弃用,但模板仍然使用旧方法。
因此,您可以:
- 将 gradle 依赖项 (
build.gradle
) 中的播放服务版本从com.google.android.gms:play-services:6.5.87
更改为com.google.android.gms:play-services:6.1.71
。
或
使用此处描述的新方法: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/