我正在开发一个Android应用程序,我在日志中得到了这个:
06-13 15:35:11.140: E/AndroidRuntime(21290): FATAL EXCEPTION: main
06-13 15:35:11.140: E/AndroidRuntime(21290): java.lang.NoClassDefFoundError: com.protocolanalyzer.andres.LogicAnalizerActivity
06-13 15:35:11.140: E/AndroidRuntime(21290): at com.multiwork.andres.MainMenu.<clinit>(MainMenu.java:37)
06-13 15:35:11.140: E/AndroidRuntime(21290): at java.lang.Class.newInstanceImpl(Native Method)
06-13 15:35:11.140: E/AndroidRuntime(21290): at java.lang.Class.newInstance(Class.java:1319)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2220)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.app.ActivityThread.access$600(ActivityThread.java:156)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1250)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.os.Handler.dispatchMessage(Handler.java:99)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.os.Looper.loop(Looper.java:137)
06-13 15:35:11.140: E/AndroidRuntime(21290): at android.app.ActivityThread.main(ActivityThread.java:5238)
06-13 15:35:11.140: E/AndroidRuntime(21290): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 15:35:11.140: E/AndroidRuntime(21290): at java.lang.reflect.Method.invoke(Method.java:511)
06-13 15:35:11.140: E/AndroidRuntime(21290): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
06-13 15:35:11.140: E/AndroidRuntime(21290): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
06-13 15:35:11.140: E/AndroidRuntime(21290): at dalvik.system.NativeStart.main(Native Method)
当我尝试运行它时,你可以看到Android没有找到我的类com.protocolanalyzer.andres.LogicAnalizerActivity,这看起来很奇怪,我的所有活动运行都很好,但是这个特定的一个给了我这个错误。以下是我从ListView启动活动的方法:
private static final Class<?>[] className = {LCView.class, FrecView.class,
LogicAnalizerActivity.class, BrazoRobot.class, PruebaParser.class};
setListAdapter(new ArrayAdapter<String>(MainMenu.this, android.R.layout.simple_list_item_1, MenuNames));
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
if(DEBUG) Log.i("MainMenu", "onListItemClick() - Position: " + position);
Intent mIntent = new Intent(MainMenu.this, className[position]);
startActivity(mIntent);
}
这是我的LogicAnalyzerActivity,您可以看到包和名称是正确的:
package com.protocolanalyzer.andres;
public class LogicAnalizerActivity extends SherlockFragmentActivity implements OnActionBarClickListener, OnNewBluetoothDataReceived{
Manifest.xml:
<activity
android:screenOrientation="landscape"
android:name="com.protocolanalyzer.andres.LogicAnalizerActivity"
android:label="@string/app_name" >
</activity>
发生了什么事?我试过了:
com.protocolanalyzer.andres.LogicAnalizerActivity.class
代替LogicAnalizerActivity.class
答案 0 :(得分:3)
您的AndroidManifest.xml文件显示android:name="com.protocolanalyzer.andres.LogicAnalizerPrefs"
,但您需要的课程实际上是android:name="com.protocolanalyzer.andres.LogicAnalizerActivity"
。
答案 1 :(得分:0)
如果您已将adt更新为rev 22,请尝试以下
右键单击项目转到属性。 Java构建路径。选择订单导出选项卡。确保选中了Android私有库。如果您已引用库项目。对图书馆项目也这样做。清洁和建设。