Can't run robospice-sample-okhttpclient: java.lang.NoClassDefFoundError

606 views
Skip to first unread message

Lucas Jota

unread,
Jan 21, 2014, 8:06:18 AM1/21/14
to robo...@googlegroups.com
I want to integrate robospice and okhttp in my project, and was trying to run this sample (without maven)... So I followed the steps below:

1- at Intellij, selected File > Import Project > robospice-sample-okhttpclient folder, then clicked next until project was created
3- at File > Project Structure, added all jars as libraries, and the respective dependencies to robospice-sample-okhttpclient module
4- Runned the project with a Nexus 4, the build was completed succesfully
5- When app is starting, I get the following error:

01-21 09:56:39.564: ERROR/AndroidRuntime(18455): FATAL EXCEPTION: main
        Process: com.octo.android.robospice.sample.basic, PID: 18455
        java.lang.NoClassDefFoundError: com.squareup.okhttp.internal.Util
        at com.squareup.okhttp.OkHttpClient.<clinit>(OkHttpClient.java:42)
        at com.octo.android.robospice.okhttp.OkHttpSpiceService.createOkHttpClient(OkHttpSpiceService.java:22)
        at com.octo.android.robospice.okhttp.OkHttpSpiceService.onCreate(OkHttpSpiceService.java:18)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:2572)
        at android.app.ActivityThread.access$1800(ActivityThread.java:135)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)

when looking into the project tree, I can´t find this com.squareup.okhttp.internal.Util class, neither at https://github.com/square/okhttp source... Am I missing something? How can I see this working on my device?

Thanks in advance for any help on this!

Lucas Jota

unread,
Jan 21, 2014, 8:49:31 AM1/21/14
to robo...@googlegroups.com
update: While reading about google http client (here), found the following warning:

WARNING: for Android, the jars MUST be placed in a directory named "libs" for the APK packager to find them. Otherwise, you will get a NoClassDefFoundError at runtime.

So I put the jars inside a libs folder, and repeated the steps above.. I'm still getting the same exception, though...

Stéphane Nicolas

unread,
Jan 21, 2014, 11:43:11 AM1/21/14
to robo...@googlegroups.com
can you list your jars please ? 

ls -lah libs/

S.


2014/1/21 Lucas Jota <lucas...@gmail.com>

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes RoboSpice.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse robospice+...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .



--
Stéphane NICOLAS,
OCTO Technology 
Développeur & Consultant Android / Java
..........................................................
50, Avenue des Champs-Elysées
75008 Paris
+33 (0)6.26.32.34.09
www.octo.com - mobilite.octo.com 
blog.octo.com - www.usievents.com
...........................................................

Lucas Jota

unread,
Jan 21, 2014, 12:05:02 PM1/21/14
to robo...@googlegroups.com
commons-io-1.3.2.jar
commons-lang3-3.2.1.jar
okhttp-1.3.0.jar
robospice-1.4.11.jar
robospice-cache-1.4.11.jar
robospice-okhttp-1.4.11.jar

thats all...

ps: I managed to run the robospice-sample-google-http-client example but there was a missing jar at the repository branch, so I downloaded google-http-client-1.17.0-rc.jar from here 
otherwise I would get the following errors:
package com.google.api.client.util does not exist
package com.google.api.client.http does not exist
cannot access com.google.api.client.http.HttpRequestFactory. class file for com.google.api.client.http.HttpRequestFactory not found
cannot access com.google.api.client.json.JsonFactory. class file for com.google.api.client.json.JsonFactory not found

Stéphane Nicolas

unread,
Jan 22, 2014, 12:56:01 AM1/22/14
to robo...@googlegroups.com
So, everything is fine for you ? 

Stéphane


2014/1/21 Lucas Jota <lucas...@gmail.com>
Reply all
Reply to author
Forward
0 new messages