java.lang.IllegalStateException: Must not set scopes in GoogleApiClient.Builder when using Auth.GOOGLE_SIGN_IN_API

大憨熊 提交于 2019-12-02 07:18:51

Try this code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstance);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}

Then set the connection code for authorization to occur:

@Override
protected void onStart() {
    super.onStart();
    mGoogleApiClient.connect();
}

I am following the documentation - Authorizing Android Apps, this documentation also provide give on how to handle ff the user has not previously authorized the application.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!