执行Android项目时出错“;活动类不存在。”;
我已经在Eclipse中创建了示例android项目,但在执行过程中出现了一个错误:活动类{com.example.best/com.example.best.MainActivity}不存在。 但项目中存在MainActivity类执行Android项目时出错“;活动类不存在。”;,android,eclipse,Android,Eclipse,我已经在Eclipse中创建了示例android项目,但在执行过程中出现了一个错误:活动类{com.example.best/com.example.best.MainActivity}不存在。 但项目中存在MainActivity类 package com.example.best; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivi
package com.example.best;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
以下是控制台上打印的错误消息
[2015-03-01 22:01:58 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:01:59 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:02 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:02 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:05 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:05 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:08 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:08 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:11 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:12 - best] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.best/.MainActivity }
[2015-03-01 22:02:12 - best] ActivityManager: Error type 3
[2015-03-01 22:02:12 - best] ActivityManager: Error: Activity class {com.example.best/com.example.best.MainActivity} does not exist.
这是我清单文件的内容
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.best"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.best.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
如何解决此问题每当在应用程序中添加新活动时,都需要在清单文件中添加新标记。确保您正在执行此操作,否则将不考虑新活动
嗯,我不能证实你的样品有任何错误。我创建了一个与您的包名相同的演示项目,粘贴了确切的清单以及MainActivity,它在我的末端工作 您的样本中没有错误。我已经在我的机器上测试过了,它工作正常 请尝试以下步骤。 项目-->清洁
如果它不起作用,那么尝试创建新的工作区这是难以置信的,但有时似乎只有重新创建整个工作区才能有所帮助。