1
我正嘗試使用Oauth 2.0連接到Google日曆。前兩天工作正常,但現在引發異常:「由:java.lang.NoSuchMethodError:com.google.api.client.util.Strings.isNullOrEmpty(Ljava/lang/String;)Z引起。連接到Google日曆時出錯
我正在使用google-api-java-client-1.14.1。 (我的圖書館裏有「google-http-client-1.14.1-beta.jar」)。
這個問題只發生在部署版本中,當我在本地機器上運行applicationaction時,一切正常。
代碼:
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("[email protected]",CalendarScopes.CALENDAR);
Calendar service = new Calendar(new NetHttpTransport(), new JacksonFactory(), sa);// here throw the exception
.
.
.
}