gpt4 book ai didi

java.lang.NoClassDefFoundError : android. support.v4.content.LocalBroadcastManager facebook android 应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:28:40 24 4
gpt4 key购买 nike

我知道有人问过这个问题,我尝试过使用许多其他帖子来帮助我解决这个问题,但都没有奏效。我正在通过此链接在 Android 应用程序上安装 Facebook 登录:https://developers.facebook.com/docs/android/getting-started .我已经导入了 Facebook SDK,它适用于示例应用程序,所以我知道没问题。我的 libs 文件夹中没有任何 JAR。在属性 > Android 库中,我添加了 appcompat_v7 和 FacebookSDK。在 Built Path > Order and Export 中,我选中了 Android Dependencies 和 Android Private Libraries。

错误

java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager

发生在这行代码上:

Session.openActiveSession(this, true, new Session.StatusCallback() {

关于为什么会发生这种情况的任何想法?我整天都在摆弄我的属性(property),无法让它发挥作用。该代码就在 FB 开发者网站上,所以我确信它没问题。谢谢。

07-23 16:19:18.506: W/dalvikvm(22318): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
07-23 16:19:18.506: W/dalvikvm(22318): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
07-23 16:19:18.506: W/dalvikvm(22318): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
07-23 16:19:18.506: W/dalvikvm(22318): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
07-23 16:19:18.506: I/dalvikvm(22318): Could not find method android.support.v4.content.LocalBroadcastManager.getInstance, referenced from method com.facebook.Session.postActiveSessionAction
07-23 16:19:18.506: W/dalvikvm(22318): VFY: unable to resolve static method 222: Landroid/support/v4/content/LocalBroadcastManager;.getInstance (Landroid/content/Context;)Landroid/support/v4/content/LocalBroadcastManager;
07-23 16:19:18.506: D/dalvikvm(22318): VFY: replacing opcode 0x71 at 0x0009
07-23 16:19:18.545: D/AndroidRuntime(22318): Shutting down VM
07-23 16:19:18.545: W/dalvikvm(22318): threadid=1: thread exiting with uncaught exception (group=0x419707c0)
07-23 16:19:18.545: E/AndroidRuntime(22318): FATAL EXCEPTION: main
07-23 16:19:18.545: E/AndroidRuntime(22318): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
07-23 16:19:18.545: E/AndroidRuntime(22318): at com.facebook.Session.postActiveSessionAction(Session.java:1567)
07-23 16:19:18.545: E/AndroidRuntime(22318): at com.facebook.Session.setActiveSession(Session.java:974)
07-23 16:19:18.545: E/AndroidRuntime(22318): at com.facebook.Session.openActiveSession(Session.java:1129)
07-23 16:19:18.545: E/AndroidRuntime(22318): at com.facebook.Session.openActiveSession(Session.java:1014)
07-23 16:19:18.545: E/AndroidRuntime(22318): at com.example.testfb3.MainActivity.onCreate(MainActivity.java:18)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.app.Activity.performCreate(Activity.java:5133)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.app.ActivityThread.access$600(ActivityThread.java:153)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.os.Looper.loop(Looper.java:137)
07-23 16:19:18.545: E/AndroidRuntime(22318): at android.app.ActivityThread.main(ActivityThread.java:5289)
07-23 16:19:18.545: E/AndroidRuntime(22318): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 16:19:18.545: E/AndroidRuntime(22318): at java.lang.reflect.Method.invoke(Method.java:525)
07-23 16:19:18.545: E/AndroidRuntime(22318): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
07-23 16:19:18.545: E/AndroidRuntime(22318): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
07-23 16:19:18.545: E/AndroidRuntime(22318): at dalvik.system.NativeStart.main(Native Method)

完整 Activity :

public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// start Facebook Login
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.newMeRequest(session, new Request.GraphUserCallback() {

// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
}
}).executeAsync();
}
}
});
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}

}

编辑

只是为了让大家了解我的设置是什么样的:

side

side

side

最佳答案

根据我的经验,此错误发生在build设置中。

我建议做如下。

单击“添加 jar ...”按钮

中选择“android-support-v4.jar”

选择“Order and Export”选项卡并勾选“android-support-v4.jar”。

清理项目并构建。

运行项目后,应用程序将执行。

祝你好运

--安德烈·亚历山大--

关于java.lang.NoClassDefFoundError : android. support.v4.content.LocalBroadcastManager facebook android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24920404/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com