我正在尝试在我正在构建的应用中使用Android的Factual驱动程序。我已经通过从我的应用程序中的libs文件夹中的here中删除.jar文件来安装他们的驱动程序。我基本上只是从here获取了演示代码并将其放入我自己的活动中,根据需要进行修改以使其初始化。
当我运行活动时,我得到一个NoClassDefFoundError指向我首先实例化Factual的行,如下所示:
protected Factual factual = new Factual("KEY", "SECRET");
我不得不对代码进行一次更改,以便Eclipse接受它。这个变化发生在下面的FactualRetrievalTask类中:
public class FactualRetrievalTask extends AsyncTask<Query, Integer, List<ReadResponse>> {
@Override
protected List<ReadResponse> doInBackground(Query... params) {
List<ReadResponse> results = new ArrayList<ReadResponse>(); //changed from Lists.newArrayList();
for (Query q : params) {
results.add(factual.fetch("restaurants-us", q));
}
return results;
}
List<ReadResponse> results = new ArrayList<ReadResponse>();
是List<ReadResponse> results = Lists.newArrayList();
,但是这给了我一个错误,上面写着“列表无法解析”。做了一点研究,我决定将其改为现在的状态。
然而,当我跑步时,我得到NoClassDefFoundError
,其指向com.google.common.collect.Lists
。我有一种感觉,我所做的改变可能是造成这种情况的原因,但我不确定如何继续解决它。任何帮助将不胜感激。以下相关日志:
04-14 17:06:01.209: E/AndroidRuntime(11688): FATAL EXCEPTION: main
04-14 17:06:01.209: E/AndroidRuntime(11688): java.lang.NoClassDefFoundError: com.google.common.collect.Lists
04-14 17:06:01.209: E/AndroidRuntime(11688): at com.factual.driver.Factual.<init>(Factual.java:46)
04-14 17:06:01.209: E/AndroidRuntime(11688): at com.factual.driver.Factual.<init>(Factual.java:57)
04-14 17:06:01.209: E/AndroidRuntime(11688): at com.example.blobtag2.PlaceActivity.<init>(PlaceActivity.java:64)
04-14 17:06:01.209: E/AndroidRuntime(11688): at java.lang.Class.newInstanceImpl(Native Method)
04-14 17:06:01.209: E/AndroidRuntime(11688): at java.lang.Class.newInstance(Class.java:1409)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1757)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1873)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.os.Looper.loop(Looper.java:150)
04-14 17:06:01.209: E/AndroidRuntime(11688): at android.app.ActivityThread.main(ActivityThread.java:4358)
04-14 17:06:01.209: E/AndroidRuntime(11688): at java.lang.reflect.Method.invokeNative(Native Method)
04-14 17:06:01.209: E/AndroidRuntime(11688): at java.lang.reflect.Method.invoke(Method.java:507)
04-14 17:06:01.209: E/AndroidRuntime(11688): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
04-14 17:06:01.209: E/AndroidRuntime(11688): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
04-14 17:06:01.209: E/AndroidRuntime(11688): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:1)
听起来你需要加入Google's guava:
java.lang.NoClassDefFoundError: com.google.common.collect.Lists