没有找到Class Def Error(android)

时间:2013-06-07 09:00:55

标签: android

我正在开发一个应用程序,我可以启动有两个按钮的Launcher活动。单击任何这些按钮时,应打开一个新活动。但是,会发生运行时错误。


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Intro extends Activity {

    Button searchBut, fbButton;

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppSettings.loadLogin(getApplicationContext());
        setContentView(R.layout.intro);
        if (AppSettings.logged) {
            Intent a = new Intent(Intro.this, AllChallengesPager.class);
            a.putExtra("logging", "0");
            startActivity(a);
        }
        searchBut = (Button) findViewById(R.id.button2);
        searchBut.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent a = new Intent(Intro.this, DetailedChallenge.class);
                a.putExtra("logging", "0");
                startActivity(a);
            }
        });
        fbButton = (Button) findViewById(R.id.fbBut);
        fbButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent a = new Intent(Intro.this, AllChallengesPager.class);
                a.putExtra("logging", "1");
                startActivity(a);
            }
        });
        AppSettings.loadLogin(getApplicationContext());
    }
}

06-07 11:26:07.776: E/AndroidRuntime(13305): FATAL EXCEPTION: main
06-07 11:26:07.776: E/AndroidRuntime(13305): java.lang.NoClassDefFoundError: com.loopj.android.http.RequestParams
06-07 11:26:07.776: E/AndroidRuntime(13305):    at com.example.challengeZygio.DetailedChallenge.onCreate(DetailedChallenge.java:216)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.app.Activity.performCreate(Activity.java:5047)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.app.ActivityThread.access$700(ActivityThread.java:134)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.os.Looper.loop(Looper.java:137)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at android.app.ActivityThread.main(ActivityThread.java:4867)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at java.lang.reflect.Method.invokeNative(Native Method)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at java.lang.reflect.Method.invoke(Method.java:511)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
06-07 11:26:07.776: E/AndroidRuntime(13305):    at dalvik.system.NativeStart.main(Native Method)

- 我的所有jar库都放在libs文件夹中   - 我已经清理了项目并重启了Eclipse几次   - 我正在使用带有所有最新更新的Eclipse Juno

4 个答案:

答案 0 :(得分:22)

Right click your Project -> Properties -> Java Build Path -> Order & Export

到达此处后,您使用的库,“选择”这些库并将它们移到列表顶部。即假设您使用了“xyz.jar”文件,那么以下将是您的序列。

[x] xyz.jar
[x] Android x.x
[x] Android依赖项 ....

清理后保存更改并重建项目。

答案 1 :(得分:1)

我也遇到了这个问题,可能有几个原因没有找到类可能是你的活动未添加到Manifest中,导入的库没有正确添加到项目中如上所述。另外一个原因可能是jar不匹配。在我的情况下,jar不匹配我的项目lib包含android-support.jar,我导入的appcompat v7有另一个版本。所以我只是删除了我的项目的libs中的android-support.jar,问题解决了。

答案 2 :(得分:0)

右键单击Project。 转到构建路径 - >配置构建路径 - >订单和出口 - >选择您使用过的所有库 - >点击确定 - >清洁项目

答案 3 :(得分:0)

我也遇到了同样的问题。后来我知道在eclipse中构建之后,没有将属性> JavaBuildPath> Library / Project添加库jar。而不是这样,直接将.jar库直接复制并粘贴到lib文件夹中,刷新项目对我有用。

相关问题