2016-05-31 66 views
2

我想运行Users.messages:列表(下面)的示例java代码。在 '执行()' 方法,但是,我的IDE(的IntelliJ)错误:Gmail API获取消息无法解析方法execute()'

'cannot resolve method execute()'

我有必要的依赖,谷歌的API服务Gmail的-V1-rev43-1.2.2.0.jar。我缺少另一个依赖项吗?

/** 
    * List all Messages of the user's mailbox matching the query. 
    * 
    * @param service Authorized Gmail API instance. 
    * @param userId User's email address. The special value "me" 
    * can be used to indicate the authenticated user. 
    * @param query String used to filter the Messages listed. 
    * @throws IOException 
    */ 
    public static List<Message> listMessagesMatchingQuery(Gmail service, String userId,String query) throws IOException { 
    ListMessagesResponse response = service.users().messages().list(userId).setQ(query).execute(); 

错误:无法解析方法execute()编译

回答

1

我有同样的问题。 尝试在gradle文件中添加这个依赖项,它解决了我的问题。

编译 'com.google.apis:谷歌API服务Gmail邮箱:V1-rev48-1.22.0'