Google Plus Android API: “The method setActions(String[]) is undefined for the type PlusClient.Builder”

孤者浪人 提交于 2019-12-11 12:17:48

问题


I am trying to make the sample Android Google+ app working... (sample app provided by Google here: https://developers.google.com/+/quickstart/android )

I am getting a compiling error on the "setAction" methods:

mPlusClient = new PlusClient.Builder(this, this, this)
                .setActions(MomentUtil.ACTIONS) // Compiling error here !
                .build();

I get "The method setActions(String[]) is undefined for the type PlusClient.Builder"

Anybody knows why I get this error ???

Thanks !!


回答1:


1) Go to SDK Manager and go to extras and select google play services and install latest update.

2) Then browse through your sdk folder like sdk/extras/google/.. You will find the library project.Import that project into workspace and add it as library to ur project.

3) Then clean build and run.




回答2:


"The method setActions(String[]) is undefined for the type PlusClient.Builder"

means you are passing String array to setActions method but as in API Doc setActions (String... actions) method takes String as action parameters instead of String Array

because setActions method takes variable arguments(Varargs) so you can pass multiple sting in setActions method without using array as:

mPlusClient = new PlusClient.Builder(this, this, this)
                .setActions(MomentUtil.ACTIONS[0],
                            MomentUtil.ACTIONS[1],....) 
                .build();



回答3:


They changed the method name from setActivities to setActions.

http://developer.android.com/reference/com/google/android/gms/plus/PlusClient.Builder.html



来源:https://stackoverflow.com/questions/19713451/google-plus-android-api-the-method-setactionsstring-is-undefined-for-the-t

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