我把IntelliJ IDEA从12.0.4升级到12.10。

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

错误:没有找到默认活动

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

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


当前回答

菜单构建→重建项目 菜单文件→无效缓存…→无效并重新启动

这对我很管用。

重新构建项目以确保项目中没有任何错误。然后我们可以使缓存失效。

其他回答

使缓存失效/重新启动



之后,你的应用程序必须运行!

我将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库,它提示我定义一个默认意图。这就解决了我的问题。

在我的案例中,AndroidManifest.xml中有一个打印错误,如下所示。删除应用程序标签上方的“o”字母就解决了这个问题。

显然,Android Studio不会检测AndroidMainfest.xml中的类型错误

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

o
<application android:name=".AppName"
             android:allowBackup="false"
             android:icon="@drawable/ic_launcher"
             android:label="@string/app_name"
             android:theme="@android:style/Theme.Light.NoTitleBar">

自从Android Studio 3.5或3.6以来,我开始找不到默认活动,我厌倦了无效缓存和重新启动,重建项目等。

事实证明,我处理多模块和清单的方式是错误的。我有默认的活动的清单在库模块,但它应该已经在两个应用程序模块。

假设库模块 appmodule1 appmodule2

Remove HomeActivity from librarymodule Manifest whatsoever. Add: class AppModuleActivity1 : HomeActivity() to appmodule1 class AppModuleActivity2 : HomeActivity() to appmodule2 To appmodule1 Manifest inside application tag, I added: <activity android:name="com.app.name.AppModuleActivity1"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Same about appmodule2 but change 2 for 1 in naming.

Android Studio 4.1解决了这个问题