我最近下载了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();
}
它是以下的重复项无法构建PlusClient https://stackoverflow.com/questions/15108235/unable-to-build-plusclient and 找不到符号类生成器 https://stackoverflow.com/questions/27389192/can-not-find-symbol-class-builder/
快速参考:
问题是 PlayClient 现在已被弃用,但模板仍然使用旧的方式。
因此,您可以:
- 更改 gradle 依赖项中的播放服务版本(
build.gradle
) from com.google.android.gms:play-services:6.5.87
to com.google.android.gms:play-services:6.1.71
.
OR
-
使用此处描述的新方法:http://android-developers.blogspot.in/2014/02/new-client-api-model-in-google-play.html 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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)