gpt4 book ai didi

android - 执行 Android 项目时出错 "Activity class does not exist."

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:30 25 4
gpt4 key购买 nike

我已经在 Eclipse 中创建了示例 android 项目,但是在执行时我收到了一个错误: Activity 类 {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 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.

这是我的 list 文件的内容

<?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>

我应该怎么做才能解决这个问题

最佳答案

您的样本没有错误。我已经在我的机器上对其进行了测试,它工作正常。

请尝试以下步骤。项目 --> 清理

如果它不起作用,则尝试创建新工作区

关于android - 执行 Android 项目时出错 "Activity class does not exist.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28796154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com