我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

正确的方法是将以下内容添加到Manifest文件中:

<activity
    android:name="FULL_NAME_OF_YOUR_ACTIVITY"
    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> </application>

不需要使缓存无效。

其他回答

在Android Studio 4.0中,请将Launch更改为Nothing:

运行/调试配置→Android应用程序→应用程序→常规→启动选项→设置启动为“无”。

去建造。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
    }
}

它非常适合我。

TL; diana:

确保您不仅检查操作和类别名称,还检查路径。特别是如果你做了重构。

我的解决方案是仔细检查AndroidManifest文件。我做了一个重构,它不仅更新了意图过滤器,而且还更新了意图过滤器名称的路径:

<!-- Type and value were added to the 
     path here when I did the refactor -->
<action android:name="android.intent.type.MAIN"/>
<category android:name="android.intent.value.LAUNCHER"/>

它应该是:

<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

有时卸载所有用户的应用程序会有所帮助。

进入“设置”中的“应用程序”列表。转到你的应用程序或滚动到列表的末尾,然后卸载它。

我有这个问题两天了。我尝试了所有可能的解决办法,但都没用。最后,我找到了一个解决方案。

以下是你需要做的:

关闭Android Studio 转到c:\ users \ username将build-cache文件夹重命名为build-cache.bak 进入C:\Users\UserName.AndroidStudio3.3\system并重命名这些文件夹 缓存到cache .bak 编译-server到编译-server.bak 把蝙蝠 转换到Conversion .bak External_build_system到External_build_system .bak Frameworks到Frameworks .bak Gradle到Gradle .bak Resource_folder_cache到Resource_folder_cache .bak 打开Android Studio,再次打开你的项目。