我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
当前回答
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"/>
其他回答
我最近也遇到了类似的问题。问题在于activitymanifest XML文件。
请检查标语是否正确关闭。
我刚刚在Android Studio 2.1.2中遇到了这个错误。
我通过添加MAIN/LAUNCHER intent-filter到flavor manifest中的默认活动来解决这个问题,尽管filter已经在默认活动中了。
它甚至在合并的清单中,但Android Studio无法找到它,直到我在两个清单中复制了过滤器。
尝试右键单击项目并选择打开模块设置。然后转到模块中的Sources选项卡,找到src文件夹,右键单击并将其标记为Sources(蓝色)。
在Android Studio的后期版本中没有源代码选项卡,但您可以编辑构建。如何在Android Studio中添加一个链接源文件夹?
前面的答案对我没有任何帮助。过了一段时间,我发现IntelliJ IDEA将动作名称改为大写。如:
<intent-filter>
<action android:name="ANDROID.INTENT.ACTION.MAIN"/>
<category android:name="ANDROID.INTENT.CATEGORY.LAUNCHER"/>
</intent-filter>
恢复正常后,IDEA识别出默认活动:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
正确的方法是将以下内容添加到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>
不需要使缓存无效。