首页 > 解决方案 > 运行“应用程序”时出错:未找到默认活动

问题描述

我确实在这里找到了多种解决方案,但它们都不适合我……我克隆了一个现有的 Androi 项目,它工作得非常好,我添加并更改了一些代码,添加了片段和片段的资源。这样做时,一切正常,但突然我得到了这个错误......

我尝试了几件事: 1. 在“编辑配置”中将“默认活动”更改为特定活动,但我得到的错误是它未在 AndroidManifest.xml 中指定(它是)。2.我尝试在清单中使用完整的包路径(“com.example.something.ActivityLogin”而不是“.ActivityLogin”)

    <activity android:name=".ActivityLogin"
        android:launchMode="singleInstance"
        android:screenOrientation="portrait"
        android:configChanges="orientation|keyboardHidden"
        android:windowSoftInputMode="adjustResize">

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

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

    </activity>
  1. 无效的缓存并重新启动
  2. 尝试重新安装 Androi Studio

现在是最疯狂的一个: 5. 删除整个项目,从 git 中拉出 master,问题仍然存在!

另外,我根本没有触及 AndroidManifest 和 ActivityLogin,我没有重构任何东西......

我不知道该往哪里看,我猜这是与 Android Studio(2018 年 10 月 9 日起为 3.2.1)相关的问题?此外,另一个项目继续运行良好......

标签: androidandroid-studio

解决方案


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

构建-清理项目或构建-重建项目


推荐阅读