1

我正在尝试使用 Oauth 2.0 连接到 Google 日历。两天前工作正常,但现在抛出异常:“引起:java.lang.NoSuchMethodError:com.google.api.client.util.Strings.isNullOrEmpty(Ljava/lang/String;)Z”。

我正在使用 google-api-java-client-1.14.1。(我的库中有“google-http-client-1.14.1-beta.jar”)。

该问题仅出现在已部署的版本中,当我在本地计算机上运行应用程序时一切正常。

代码:

public GoogleCredential conexion(String email, String scope) { 

    GoogleCredential credential =null;
    try{

        // Build service account credential.
        credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
        .setJsonFactory(JSON_FACTORY)
        .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
        .setServiceAccountScopes(scope)
        .setServiceAccountPrivateKeyFromP12File(new File(file))
        .setServiceAccountUser(email)
        .build();
    }
    catch(Exception e){
        e.printStackTrace();

    }


return credential;

}


public int function(){
    GoogleCredential sa = serviceAc.conexion("user@mail.com",CalendarScopes.CALENDAR);

    Calendar service = new Calendar(new NetHttpTransport(), new JacksonFactory(), sa);//   here throw the exception
.
.
.
}
4

1 回答 1

0

根据java.lang.NoSuchMethodError您尝试调用在编译时类路径中可用且在运行时类路径中不再可用的方法,请检查此答案

所以,方法没有这样的错误(实际上你应该在这里发布完整的错误)这个方法在运行时不再受支持所以你所要做的就是搜索这个方法及其支持的新类,你会在一个新的罐

于 2013-05-17T12:30:14.623 回答