我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

有时会出现这种错误,因为Android Studio的错误行为,因为内部缓存和项目构建系统。即使我们已经为默认活动完美地设置了一切。

对于这样的问题,我找到了一个解决方案,它是为我工作。

步骤1。Android Studio→菜单文件→无效缓存,关闭Android Studio。

步骤2。进入路径C:\Users\USER.AndroidStudio3.2\system

步骤3。更改名称扩展为下面文件夹的.back

  Example: compiler should be *compiler.back*

编译器 compiler-server 转换 external-build_system 框架 gradle resource_folder_cache

步骤4:启动Android Studio并打开项目。

其他回答

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

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

这是在我的电脑意外重启后发生的。奇怪的是,我没有做任何修改,仍然得到这个错误。

以上这些对我都没有帮助。解决我问题的,是这个。

步骤1:

步骤2:

步骤3:

如果这不能解决问题,再试试别的办法。

试1:

菜单文件→无效缓存/重启…

试2:

检查以下两行,

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

在文件manifest.xml中的启动器活动声明中。

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

试3:

如图所示: 打开“运行/调试配置”。

如果这也无济于事:

尝试4:

菜单文件→导出到ZIP。

and

将其作为一个新项目导入。

尝试右键单击项目并选择打开模块设置。然后转到模块中的Sources选项卡,找到src文件夹,右键单击并将其标记为Sources(蓝色)。

在Android Studio的后期版本中没有源代码选项卡,但您可以编辑构建。如何在Android Studio中添加一个链接源文件夹?

编辑文件androidmanifest.xml

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivityName">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

我将Intent-filter改为

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

只需要添加DEFAULT选项。我正在使用Process Phoenix库,它提示我定义一个默认意图。这就解决了我的问题。