我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

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

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

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

其他回答

我最近也遇到了类似的问题。问题在于activitymanifest XML文件。

请检查标语是否正确关闭。

这个解决方案100%有效

你一定看到了这个:

首先,打开舱单,检查是否有这个,

  <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>

如果不存在,添加它

如果出现上述情况,但仍然看不到默认活动,请执行以下步骤:

点击编辑配置 在单击edit configuration时,您将看到启动选项被设置为DEFAULT ACTIVITY 把它变成什么都没有。

问题解决了!

Note

请在清单文件的根文件中写明你应该有包名

        <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
        package="com.package.name">

去建造。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 Manifest.xml中,像下面这样设置启动活动:

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

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

在配置新项目时

公司名称应该以.app结尾。例如,它应该是android.example.com.app 它不应该是android.example.com。