NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager [duplicate]

佐手、 提交于 2019-12-06 10:55:44

问题


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.


回答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 !!




回答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



来源:https://stackoverflow.com/questions/17674491/noclassdeffounderror-android-support-v4-content-localbroadcastmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!