android java.lang.NoClassDefFoundError即使类IS存在

时间:2014-11-21 19:15:05

标签: java android eclipse adt eclipse-adt

跳到下面的 EDIT 部分 - 新项目设置和新问题。我把这些原始内容留在了上下文中......

我的Android项目中出现了NoClassDefFoundError - 在这种情况下,它抱怨它无法找到我刚添加的UserVoice插件:

stack trace

由此代码触发:

package com.mycompany.myapp;
...
import com.uservoice.uservoicesdk.Config;
import com.uservoice.uservoicesdk.UserVoice;
...
public class MyActivity extends Activity {
    ...
    public void onCreate(Bundle savedInstanceState) {
        ...
        super.onCreate(savedInstanceState);
        ...
        _configureFeedbackWidget();
    }

    private void _configureFeedbackWidget() {
        // It gets past this code, which contains stuff in the same 
        // "uservoicesdk" package as the problem class. 
        Config config = new Config("myapp.uservoice.com");
        UserVoice.init(config, this);
    }

    public void showFeedbackWindow(View v) {
        // Triggered by a button on the page
        UserVoice.launchUserVoice(this);  // Error is triggered by this line
    }
    ...
}

但是,我破解了已安装的.apk(使用dex2jar),并手动验证了它所抱怨的PortalActivity类是否存在:

apk contents

什么可能导致Android找不到课程?



编辑:
我已经改变了我的项目依赖性& Java Build Path设置,这就是我现在所拥有的:

Build Path - Projects Build Path - LibrariesBuild Path - Order and Export

我清理/重建 - 没有错误,现在我看到以下内容:

  1. MyApp.apk中不再包含com.uservoice.uservoicesdk包。该软件包现在位于PortalActivity.apk中,我可以从控制台看到,它与我的.apk分开安装。

    控制台输出:
  2.   

    将MyApp.apk上传到设备'LG-MS770-275bcf0'上   安装MyApp.apk ...
      成功!
      找到项目依赖项,安装:PortalActivity
      将PortalActivity.apk上传到设备'LG-MS770-275bcf0'上   安装PortalActivity.apk ...
      成功!
      在设备LG-MS770-275bcf0上启动com.mycompany.myapp.MyActivity活动

    1. 现在我的应用程序在上面的_configureFeedbackWidget()方法中死亡,错误为java.lang.NoClassDefFoundError: com.service.uservoicesdk.Config
    2. 那么,从我的项目中引用PortalActivity项目的正确方法是什么,这样我的项目可以在运行时找到PortalActivity的类 ,而不仅仅是在构建时?

0 个答案:

没有答案