我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

在Android Manifest.xml中,像下面这样设置启动活动:

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

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

其他回答

你可以通过进入“编辑配置”菜单(点击“Shift”三次,然后输入“编辑配置”)让Android Studio不抱怨。然后更改启动选项→启动为“无”。

进入清单→合并清单标签(屏幕底部)。

在右边的面板中,如果有任何错误,请解决它!

这就是我的解决方案(一个工具错误:不需要替换)。

去建造。Gradle(项目:xyz)

buildscript {
    repositories {
        jcenter() 
        google()
    }
allprojects {
    repositories {
        jcenter()
        google()
    }

// Just place 'google()' to the top of 'jcenter()'

buildscript {
    repositories {
        google()
        jcenter()
    }
allprojects {
    repositories {
        google()
        jcenter()
    // enter code here
    }
}

它非常适合我。

我也面临着同样的问题。在我的例子中,我不止一次地声明了一个活动。删除重复的活动后,错误得到解决。

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

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