【问题标题】:Can't find "this" class NoClassDefFoundError - Android找不到“这个”类 NoClassDefFoundError - Android
【发布时间】:2013-05-20 11:38:27
【问题描述】:

我正在尝试非常简单地测试 3.0 Facebook 入门指南。 https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/

我在导入和引用方面遇到了一些问题,但我不知道这是否相关。我遇到的问题是当我尝试运行测试 Activity ant 时出现此错误:

Could not find class 'com.test1.test2.FacebookLogin$1', referenced from method com.test1.test2.FacebookLogin.onCreate

代码:

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


        //Error occurs here when I use 'this'
        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() {

                    // 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() + "!");
                            }

                    }
                  });

              }
          }
        });
    }

当我使用this 时,如何获得NoClassDefFoundError

更新:

在使用 Scrumtious 教程 https://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/authenticate/ 进行测试后,我在调用 Session.StatusCallback() 方法时也遇到了同样的错误。我仍然不知道我的问题是什么。

感谢您的帮助

【问题讨论】:

  • 您似乎也在使用super 而不仅仅是this
  • @ZouZou 谢谢,但我没有
  • FacebookLogin$1 表示它是 facebooklogin 中的匿名类,也许是 Session.StatusCallback?它是 facebook api 的一部分吗?你会把它上传到你的安卓设备吗?
  • @user902383 是的,这似乎是一些问题。我现在尝试使用 Scrumptious 测试应用程序并在调用 new Session.StatusCallback() 时遇到相同的错误,您是否知道它可能是什么,是的,我将它上传到我的设备。谢谢

标签: java android facebook reference noclassdeffounderror


【解决方案1】:

也许您已更新到 Android sdk 工具修订版 22。那里存在问题。您必须在导出路径中添加您使用的库。检查:
Android Sdk tools Revision 22 issue?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多