使用Guava的Iterables.any()编译时间错误

Nic*_*ner 0 java google-app-engine compiler-errors guava

我收到以下代码的错误:

Iterables.any(Lists.<String>newArrayList(), new Predicate<String>() {
  @Override
  public boolean apply(final String arg0) {
    // TODO Auto-generated method stub
    return false;
  }
});
Run Code Online (Sandbox Code Playgroud)

错误:

Iterable<T>, Predicate<? super T>类型Iterables中的方法any()不适用于arguments(ArrayList<String>, new Predicate<String>(){})

我究竟做错了什么?我觉得我犯了一个愚蠢的错误.

Nic*_*ner 6

糟糕 - 我使用了错误的导入.

正确:

import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
Run Code Online (Sandbox Code Playgroud)

不正确:

import com.google.appengine.repackaged.com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
Run Code Online (Sandbox Code Playgroud)

使用repackaged番石榴会导致问题.