java.lang.NoClassDefFoundError when crouton library in eclipse
Asked Answered
C

5

3

I was finally able to find my crouton library, after getting solutions for this question on SO. I was directed to maven central where i downloaded crouton-1.8.4 the third of size 24kb on a list at the bottom of the page. Then i copied it into the libs folder in my android project, added it to build path, and checked it in the order and export panel.

This solved the problem i was facing then in the question i asked before.

The code i tried to run was Crouton.makeText(this, "BAD Crouton", Style.ALERT); just to see if it works. I i'm testing it on a 4.4.2 emulator. And i also tried it on a 2.2 emulator, after adding the Style.Builder, which it requires to work on lower devices. i get the same problem.

But when my joy was short-lived, because when i tested it on the emulator, here is the error i got in my logcat.

 01-17 03:15:44.537: E/AndroidRuntime(2203): FATAL EXCEPTION: main
 01-17 03:15:44.537: E/AndroidRuntime(2203): Process: com.example.dester, PID: 2203
 01-17 03:15:44.537: E/AndroidRuntime(2203): java.lang.NoClassDefFoundError: de.keyboardsurfer.android.widget.crouton.Style
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at com.example.dester.MainActivity.onCreate(MainActivity.java:17)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.app.Activity.performCreate(Activity.java:5231)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.os.Handler.dispatchMessage(Handler.java:102)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.os.Looper.loop(Looper.java:136)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at android.app.ActivityThread.main(ActivityThread.java:5017)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at java.lang.reflect.Method.invokeNative(Native Method)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at java.lang.reflect.Method.invoke(Method.java:515)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 01-17 03:15:44.537: E/AndroidRuntime(2203):    at dalvik.system.NativeStart.main(Native Method)

When i first got the error i thought it must be something simple, so i cleaned and rebuilt it again and still got the same error. Then i searched for info on java.lang.NoClassDefFoundError and i found out that it had something to do with VM not being to locate a class that it was asked to load. In this case that would be the Style class.

I have spent almost 24 hours on this and have tried lots of solutions, all too no avail.

Just incase, my java compiler compliance level is 1.6 and i using JRE6 Thanks

Cinelli answered 17/1, 2014 at 8:36 Comment(3)
I'm assuming you're using Crouton 1.8.2, as there is no 1.8.4 yet. Please add the code you're using to reference it in your project to your question. The file with the checksum "ba14b78124a9945dab574c195b8b60633fd61f99" contains the Style.class.Yarkand
Have you pasted the jar file in libs folderAftereffect
@keyboardsurfer yeah its 1.8.2 sorry about that. Yes i am using the file with the checksum you stated.Cinelli
M
2

If you don't need any of the new features in Crouton 1.8.2, try 1.8.1 (https://github.com/keyboardsurfer/Crouton/wiki/Changelog). I have the exact same problem, however everything works when I use 1.8.1. I've been struggling with this same issue also, and have not yet found a solution. I'm wondering if it has something to do with the fact that it's using Java 1.7 now...

Methuselah answered 18/1, 2014 at 13:12 Comment(0)
Y
2

Crouton 1.8.3 has been released and rolled back to Java 6 source compatibility. Using this version should solve the issue.

Yarkand answered 4/2, 2014 at 15:41 Comment(0)
B
0

Right Click on Your Project> choose Build Path> Configure Build Path> Go to Order & Export Tab and do check the crouton-1.8.2.jar(the jar you added for crouton )At last OK.

Then try clean the project and Run again.

Blacksnake answered 17/1, 2014 at 8:46 Comment(0)
E
0

Go to Project->Properties->Java Build Path than select Order and export tab. Set android-support-v4.jar library checked and up it into top of the list. And then clean and rebuild project.

Ermeena answered 17/1, 2014 at 9:0 Comment(0)
M
0

This is probably due to an incompatibility between your build system and the way the jar file was created. The Crouton library only consists of a single package, so it is very easy to add it in your application and get rid of the jar. Just add the code under this folder in your project. You only need the latest SDK and you are good to go.

Mixie answered 4/2, 2014 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.