我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

转到清单文件。然后合并清单文件,看到一个错误,并解决清单问题。

清理项目并运行。

其他回答

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

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

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

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

步骤3:保存更改并完成

祝你好运

由于这个问题是关于清单的大量问题的“着陆页”,导致没有发现Default Activity,这里还有另一件事要检查是否有此问题。

打开清单并切换到合并清单选项卡。

有时问题与将项目中的所有清单合并为一个有关,这可能导致错误,因此“未找到默认活动”。问题是,据我所知,除了这个合并清单选项卡,这个错误没有显示在任何地方。

例如:在项目minSdkVersion 10中,在build中降低实现的版本。Gradle文件:从25.4.0到25.3.1解决了这个问题。

dependencies {
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support:design:25.3.1'
    implementation 'com.android.support:mediarouter-v7:25.3.1'

TouchBoarder几乎做到了。尽管选择“不启动活动”会导致什么都不启动。

在Android Studio中运行/调试配置→Android应用程序→常规→活动→选择“启动”选项:

选择你的活动。这并没有完全修复预期的行为,而是正确地覆盖它。

虽然很丑,但对我很管用:

我有这个错误消息,我的问题是在一个模块。我只是删除了应用程序标签完全从我的模块的清单和它工作。

(同时从模块库中删除ic_launcher。)

它是:

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

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name="com.example.mymodule.MainActivity"
            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>

</manifest>

Now:

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

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23"/>

</manifest>

好吧,我有时不理解Android Studio……

我遇到了同样的问题,并尝试了这里的答案,但无济于事。

然后我改变了一件事:我的intent-filter中的动作名称全部用大写。我把它改为小,只留下大写的单词MAIN,它解决了这个问题!多么荒谬!