0

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:

jar files

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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Rohodude
  • 495
  • 2
  • 5
  • 18

1 Answers1

0

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) is swallowing 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.

I would say figure out the exact location of the issue.
Sameer Sawla
  • 729
  • 6
  • 20
  • Good point, but how do I exactly pinpoint the location of the issue. Forgive me, I am a 13 year old beginner. – Rohodude Dec 01 '13 at 01:07
  • @Rohodude : I am really glad to meet students like you who start programming really early. I was very late to start on with it. As far as finding the issue in your code 'com.example.foodsaver2.DatabaseFiller.onCreate(DatabaseFiller.java:70)' This says you might have issue in the onCreate() method. Just check up there. During development, I would suggest you print the stack trace in every catch that you have. try { ... } catch(Exception e) { e.printStackTrace(); } This would help you reach to the crux of the issue. – Sameer Sawla Dec 01 '13 at 01:29
  • Thanks, I'll take a look at it. I'll comment when I find something. – Rohodude Dec 01 '13 at 01:31
  • For some reason, the code is still stuck in the try method. When I added `e.printStackTrace()` to the catch method, nothing showed up in the Logcat. The only thing that showed up was the cause of the crash of the app. Help is needed! (and appreciated) – Rohodude Dec 01 '13 at 01:39