没有外部jar的android中的NoClassDefFoundError

时间:2012-07-13 06:46:52

标签: android noclassdeffounderror

我今天才开始使用Android应用程序,所以我没有添加任何jar。我目前正在使用sdk和adt r19,如果有帮助的话。 android清单的外观如何

    <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".LoginActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".UserHome"></activity>
</application>

怎么回事:

btnLogin.setOnClickListener(new OnClickListener(){
 public void onClick(View arg0){
      Intent mapIntent = new Intent(LoginActivity.this, UserHome.class);
      LoginActivity.this.startActivity(mapIntent);
      Log.i("Intent", "Login to UserHome");
   }
});

我对为什么会发生这种情况一无所知。

修改

错误日志

07-13 06:14:06.844: E/AndroidRuntime(442): FATAL EXCEPTION: main
07-13 06:14:06.844: E/AndroidRuntime(442): java.lang.NoClassDefFoundError: com.srd.application.UserHome
07-13 06:14:06.844: E/AndroidRuntime(442):  at com.srd.application.LoginActivity$1.onClick(LoginActivity.java:70)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.View.performClick(View.java:2408)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.View.onKeyUp(View.java:4121)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.widget.TextView.onKeyUp(TextView.java:4431)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.KeyEvent.dispatch(KeyEvent.java:1061)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.View.dispatchKeyEvent(View.java:3740)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
07-13 06:14:06.844: E/AndroidRuntime(442):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1667) 
07-13 06:14:06.844: E/AndroidRuntime(442):  at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1102)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.app.Activity.dispatchKeyEvent(Activity.java:2063)
07-13 06:14:06.844: E/AndroidRuntime(442):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1643)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.os.Looper.loop(Looper.java:123)
07-13 06:14:06.844: E/AndroidRuntime(442):  at android.app.ActivityThread.main(ActivityThread.java:4627)
07-13 06:14:06.844: E/AndroidRuntime(442):  at java.lang.reflect.Method.invokeNative(Native Method)
07-13 06:14:06.844: E/AndroidRuntime(442):  at java.lang.reflect.Method.invoke(Method.java:521)
07-13 06:14:06.844: E/AndroidRuntime(442):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-13 06:14:06.844: E/AndroidRuntime(442):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-13 06:14:06.844: E/AndroidRuntime(442):  at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:1)

您是否在应用程序的清单文件中定义了 use-library 标记?

<uses-library android:name="com.google.android.maps" />

 <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <uses-library android:name="com.google.android.maps" />

    .
    .
     .
</application>

同时检查您的申请是否包含Google-api而不是Android