The method execute() is undefined for the type Mirror.Accounts.Insert

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 18:28:32

问题


I am creating a server side Dynamic Web Project using Java and Eclipse IDE for Google Glass Mirror API. In my web project I have a lib folder under WEB-INF

In the lib folder i have added the following .jar files

  • google-api-client-1.18.0-rc-sources.jar

  • google-api-services-mirror-v1-rev66-1.19.0.jar

  • google-collections-1.0-rc2.jar

  • google-http-client-1.18.0-rc.jar

  • google-http-client-jackson-1.19.0.jar

My server side code is

 @SuppressWarnings("serial")
    public class GlassAuthenticateUser extends HttpServlet{

public static Mirror getMirrorService() throws GeneralSecurityException,
IOException, URISyntaxException {
    HttpTransport httpTransport = new NetHttpTransport();
    JacksonFactory jsonFactory = new JacksonFactory();

    GoogleCredential credential = new GoogleCredential.Builder()
    .setTransport(httpTransport)
    .setJsonFactory(jsonFactory)
    .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
    .setServiceAccountScopes(MIRROR_ACCOUNT_SCOPES)
    .setServiceAccountPrivateKeyFromP12File(
            new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
            .build();
    Mirror service = new Mirror.Builder(httpTransport, jsonFactory, null)
    .setHttpRequestInitializer(credential).build();
    return service;
}

public static void createAccount(Mirror mirror, String userToken, String accountName,
        String authTokenType, String authToken) {
    try {
        Account account = new Account();
        List<AuthToken> authTokens = Lists.newArrayList(
                new AuthToken().setType(authTokenType).setAuthToken(authToken));
        account.setAuthTokens(authTokens);
        mirror.accounts().insert(
                userToken, ACCOUNT_TYPE, accountName, account).execute();
    } catch (IOException e) {
        e.printStackTrace();
    }
}


public void doGet(HttpServletRequest request,HttpServletResponse response)
            throws ServletException, IOException{

     //TO DO             
     }
}

}

I am getting the following error

The method execute() is undefined for the type Mirror.Accounts.Insert

Why is that so? I have download the latest Google API java client and used them in my project. However, it is unable to also resolve the GoogleCredential class

Can anyone suggest which .jar files should I be adding to resolve this issue?


回答1:


It looks like you have the source jar for google-api-client-1.18.0-rc, when you need the class jar. You should be able to download the latest bundle from https://code.google.com/p/google-api-java-client/wiki/Downloads?tm=2 and then extracting google-api-java-client/libs/google-api-client-1.18.0-rc.jar from the downloaded zip file.



来源:https://stackoverflow.com/questions/25707789/the-method-execute-is-undefined-for-the-type-mirror-accounts-insert

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