NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager

14,743

Solution 1

This problem was hounding me for almost Six months now and no solution was helping me but today I have managed to find the correct solution on my own.

When you select you project target version to be more than or equal to Android 4.0 Android SDK includes "android-support-v4.jar" file in your projects "libs" folder.This jar contains all the classes and methods related Android 4.0 or later

You can see your problem, android is trying to find the class definition which is in "android-support-v4.jar" so that means you have not configured the build path to the "android-support-v4.jar" file.To do this follow these steps:

1.Open your project properties
2.Select "Java Build Path" from left side menu
3.Select "Libraries" tab
4.Press "Add External Jar"
5.MOST IMPORTANT STEPS :-
Select "android-support-v4" jar file of "libs" folder of YOUR CURRENT PROJECT LOCATION(Path Should be of your project only and not the android sdk).
6.Select "Order and Export" tab and "TICK" the checkbox of "android-support-v4.jar"

That's it, your done !!

Solution 2

Don't add jar files in Build-path follow these steps

Remove all jar files from java build path and follow these steps

You should try this:

  1. Remove all references to the JAR in your project from Java

project -> properties -> Java build path -> libraries

  1. Create a libs folder if not exist at the root of your project Copy the JAR into the libs folder.

  2. If still not running OK. Right click your project > Android Tools > Fix Project Properties

clean your project and run. it will work

Share:
14,743
Jeremy Piednoel
Author by

Jeremy Piednoel

Mobile Software Engineer : Swift, NodeJS

Updated on June 09, 2022

Comments

  • Jeremy Piednoel
    Jeremy Piednoel almost 2 years

    i read a lot of topic about this error : E/AndroidRuntime(16097): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager

    i just link facebook sdk to my project, compil is ok, but with the following code i got the error

    here is my Java Build Path : http://i.stack.imgur.com/GzqO5.png

        Session.openActiveSession(this, true, new Session.StatusCallback() {
    
          // callback when session changes state
          @Override
          public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened()) {
    
              // make request to the /me API
              Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
    
                @Override
                public void onCompleted(GraphUser user, Response response) {
                    // TODO Auto-generated method stub
    
                }
    
                // callback after Graph API response with user object
              });
            }
          }
        });
    

    thanks a lot.

  • Jeremy Piednoel
    Jeremy Piednoel almost 11 years
    tyvm, i did all the step but le #3 doesn't work i have now error of compilation : import com.google.gson.Gson; look at my files : img837.imageshack.us/img837/3245/t901.png
  • Jeremy Piednoel
    Jeremy Piednoel almost 11 years
    when i remove the facebook reference everything is ok : img90.imageshack.us/img90/6048/pnbq.png
  • Jeremy Piednoel
    Jeremy Piednoel almost 11 years
    ok it was a miss match between my two android-support-v4.jar, thx a lot for your help.
  • Rohit
    Rohit almost 10 years
    Very Thanks to @Rauf, This is the exact solution.
  • khushbu
    khushbu almost 10 years
    Thanks @Rauf,I have same problem and solved it.
  • beginner
    beginner almost 8 years
    thanks rauf .. this is the best solution, saved a lot of time,