我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

这仍然发生在Android Studio 4.0,所以我必须删除以下文件夹来解决这个问题:

C:\Users\ my_user_name.AndroidStudio4.0 \ system \缓存

其他回答

这仍然发生在Android Studio 4.0,所以我必须删除以下文件夹来解决这个问题:

C:\Users\ my_user_name.AndroidStudio4.0 \ system \缓存

编辑文件androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.java2">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivityName">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

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

退出Android Studio。

进入路径C:\Users\YOUR_WINDOW_USER_NAME.AndroidStudio3.3\system

删除“/ cached”文件夹和“/tmp”文件夹。

我刚刚在Android Studio 2.1.2中遇到了这个错误。

我通过添加MAIN/LAUNCHER intent-filter到flavor manifest中的默认活动来解决这个问题,尽管filter已经在默认活动中了。

它甚至在合并的清单中,但Android Studio无法找到它,直到我在两个清单中复制了过滤器。