I have encountered a problem when using Factual API in my Android app. I think I've added all the correct jar files. Take a look here:
Here is my logcat:
11-30 19:27:03.033: E/AndroidRuntime(4538): FATAL EXCEPTION: main
11-30 19:27:03.033: E/AndroidRuntime(4538): Process: com.example.foodsaver2, PID: 4538
11-30 19:27:03.033: E/AndroidRuntime(4538): java.lang.NoClassDefFoundError: com.factual.driver.Factual
11-30 19:27:03.033: E/AndroidRuntime(4538): at com.example.foodsaver2.DatabaseFiller.onCreate(DatabaseFiller.java:70)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.app.Activity.performCreate(Activity.java:5243)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.app.ActivityThread.access$700(ActivityThread.java:135)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.os.Handler.dispatchMessage(Handler.java:102)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.os.Looper.loop(Looper.java:137)
11-30 19:27:03.033: E/AndroidRuntime(4538): at android.app.ActivityThread.main(ActivityThread.java:4998)
11-30 19:27:03.033: E/AndroidRuntime(4538): at java.lang.reflect.Method.invokeNative(Native Method)
11-30 19:27:03.033: E/AndroidRuntime(4538): at java.lang.reflect.Method.invoke(Method.java:515)
11-30 19:27:03.033: E/AndroidRuntime(4538): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
11-30 19:27:03.033: E/AndroidRuntime(4538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
11-30 19:27:03.033: E/AndroidRuntime(4538): at dalvik.system.NativeStart.main(Native Method)
What's wrong here? What am I doing wrong? And by the way, here is part of my AndroidManifest:
application android:label="@string/app_name">
<uses-library android:name="com.factual.driver.Factual" />
<activity android:name=".DatabaseFiller" android:label="@string/app_name">
And from line 70 of DatabaseFiller:
/*this is line 69, next line is 70*/ try {
Factual factual = new Factual("perosnal", "personal");
factual.fetch("products-cpg-nutrition",
new Query().search("028367831679"));
// row filter
Query q = new Query();
factual.fetch("products-cpg-nutrition",
q.or(q.field("upc").isEqual("028367831679"),
q.field("ean13").isEqual("028367831679")));
Toast.makeText(getApplicationContext(), (CharSequence) q, Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
}
What's wrong here? I'm been banging my head on the wall for a while now. I have checked SO and Google, but I can't pin the needle on the solution. Any help is greatly appreciated.
EDIT! Another message is also showing up in Logcat that I forgot to add:
11-30 20:44:09.993: E/dalvikvm(11654): Could not find class 'com.factual.driver.Factual', referenced from method com.example.foodsaver2.DatabaseFiller.onCreate
But I have it in my AndroidManifest file. Any help would be appreciated.
Please do not treat this as an answer, rather as a comment. I do not have privilege to comment yet. Please do not negate it as well.
As of what I comprehend :
The line you mentioned, cannot be the location of error. Because if it would had encountered any issue in the try block, your code
(try and catch)
isswallowing the exception stopping it from throwing an exception
.This is possibly the wrong spot where you are searching for error.
Moreover, if it is not able to recognize
'Factual'
in instance creation it would give a compilation error not a runtime exception.