1

I'm running the following code in my Runnable Class and getting an error. Both the code and the error are detailed below.

Code :

public class RunnableJob implements Runnable {

public Products products = new Products();

@Override
public void run() {
    products
            .productsField( "search", "iphone" );

/* Make the Request */
    try {
        JSONObject results = products.getProducts();
        Log.i("System.out", results.getString("code"));
    } catch (Exception e) {
        e.printStackTrace();
        Log.i("error", "hit the exception");
    }

}
}

This is the error we're getting:

07-17 12:16:51.766  11535-11550/com.example.jesarshah.snapcart E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-197
Process: com.example.jesarshah.snapcart, PID: 11535
java.lang.NoSuchMethodError: No direct method <init>(Ljava/io/InputStream;)V in class Lorg/json/JSONTokener; or its super classes (declaration of 'org.json.JSONTokener' appears in /system/framework/core-libart.jar)
        at com.semantics3.api.Semantics3Request.fetch(Semantics3Request.java:92)
        at com.semantics3.api.Semantics3Request.runQuery(Semantics3Request.java:220)
        at com.semantics3.api.Semantics3Request.get(Semantics3Request.java:263)
        at com.semantics3.api.Semantics3Request.get(Semantics3Request.java:255)
        at com.semantics3.api.Products.getProducts(Products.java:21)
        at com.example.jesarshah.snapcart.RunnableJob.run(RunnableJob.java:30)
        at java.lang.Thread.run(Thread.java:818)
honeysingh
  • 23
  • 4
  • Um..there's no such method. There seems to be an error with the semantics3request. I would read here. Seems to talk about this error http://stackoverflow.com/questions/18231134/how-to-avoid-java-lang-nosuchmethoderror-org-apache-poi-util-ioutils-copyljava – cjds Jul 17 '15 at 19:27

1 Answers1

0

You have a dependency on an old version of org.json (probably in some other package that also depends on org.json)

I solved this by explicitly defining the dependency in pom.xml

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20141113</version>
    </dependency>

(If you are using something other than Maven for dependency management you will have a similar change you need to make.)

Rob
  • 715
  • 5
  • 9