我把IntelliJ IDEA从12.0.4升级到12.10。

现在我的Android项目中的所有模块都给出了错误:

错误:没有找到默认活动

我恢复到12.0.4,一切都恢复正常了。

什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。


当前回答

这是在我的电脑意外重启后发生的。奇怪的是,我没有做任何修改,仍然得到这个错误。

以上这些对我都没有帮助。解决我问题的,是这个。

步骤1:

步骤2:

步骤3:

如果这不能解决问题,再试试别的办法。

试1:

菜单文件→无效缓存/重启…

试2:

检查以下两行,

<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

在文件manifest.xml中的启动器活动声明中。

<activity
        android:name="com.your.package.name.YourActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

试3:

如图所示: 打开“运行/调试配置”。

如果这也无济于事:

尝试4:

菜单文件→导出到ZIP。

and

将其作为一个新项目导入。

其他回答

如果您的应用程序没有活动(例如,只有一个服务),请将运行/调试配置“启动”选项更改为Nothing。

TL; diana:

确保您不仅检查操作和类别名称,还检查路径。特别是如果你做了重构。

我的解决方案是仔细检查AndroidManifest文件。我做了一个重构,它不仅更新了意图过滤器,而且还更新了意图过滤器名称的路径:

<!-- Type and value were added to the 
     path here when I did the refactor -->
<action android:name="android.intent.type.MAIN"/>
<category android:name="android.intent.value.LAUNCHER"/>

它应该是:

<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

正确的方法是将以下内容添加到Manifest文件中:

<activity
    android:name="FULL_NAME_OF_YOUR_ACTIVITY"
    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> </application>

不需要使缓存无效。

在我的例子中,我重构了一个名为“activity”的成员变量。我把它重命名为“context”…

我发现重构是对清单中的活动标记进行的,我发现它们是上下文标记……这是非常愚蠢的Android Studio方面!

我从一个演示应用程序开始,并对其进行了修改。我改变java路径内的源从com -> example -> foo到我自己和编辑清单;然而,Android Studio(0.8.7)却非常困惑。

我尝试了上面列出的所有方法,但没有一种对我有效。也许它甚至让事情变得更糟?

我的最终解决方案是编辑<projectname>。在Android Studio(又名文本编辑器)中打开。idea子目录下的iml。

之前:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>

我(重新)添加了src目录(第二行)。 后:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>

保存后,Android Studio重新加载并开始正常运行。