【问题标题】:Error connecting to Google Calendar连接到 Google 日历时出错
【发布时间】:2013-05-17 11:28:13
【问题描述】:

我正在尝试使用 Oauth 2.0 连接到 Google 日历。两天前工作正常,但现在抛出异常:“Caused by: 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
.
.
.
}

【问题讨论】:

    标签: google-app-engine gwt oauth-2.0 google-calendar-api google-api-java-client


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多