Every time I try to use a 3rd-party library in my business logic, I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonObject
I’ve even tried using alternative libraries, but they return the same error. Whether I deploy the code or run it on CodeRunner.
I’ve added the library’s JAR to the project’s libs folder. Is there something else I am forgetting to do?
Also, this question was not solved* but it is marked as solved? I have beens struggling to successfully use 3rd-party libraries with Business Logic for weeks now.
From everything I’ve read / found, having the JAR in my libs folder (as pictured) is supposed to suffice. But clearly it is not being imported properly as when I run it via CodeRunner it says the files can’t be found.
I put together a sample timer which uses the gson-2.5.jar library. I had no problem deploying that code. Here’s a link to the complete project - you just need to add your app id and secret key. Please give it a try and let me know if it works: