我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

如果您已经有<intent-filter>标记,请确保您正确地关闭了所有标记。

我的错误是我用</>而不是</activity>关闭了<activity>标签。

其他回答

在我的案例中,AndroidManifest.xml中有一个打印错误,如下所示。删除应用程序标签上方的“o”字母就解决了这个问题。

显然,Android Studio不会检测AndroidMainfest.xml中的类型错误

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

o
<application android:name=".AppName"
             android:allowBackup="false"
             android:icon="@drawable/ic_launcher"
             android:label="@string/app_name"
             android:theme="@android:style/Theme.Light.NoTitleBar">

如果你的应用有一个默认的启动活动,这可能是你的错误:

步骤1:选择“编辑配置”

步骤2:注意这个警告:未找到默认活动

第三步:选择一个默认活动

步骤3:保存更改并完成

祝你好运

我也遇到过同样的问题。由于某些原因,Android Studio将大部分XML文件中的所有Android:name属性(包括manifest)替换为Android:subject (Android Studio无法识别)。

正如你在上图中看到的,IDE不识别android:subject属性。因此,它将无法读取指定mainactivity的行。

解决方案是简单地改变每个android:受制于android:name,然后从Build菜单中重建项目*→重建项目。在重新构建项目时,您可能会遇到相同的问题,因此执行与上面相同的操作。

我将Intent-filter改为

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

只需要添加DEFAULT选项。我正在使用Process Phoenix库,它提示我定义一个默认意图。这就解决了我的问题。

检查AndroidManifest.xml文件中的应用程序标记中是否存在活动标记。