我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
当前回答
在我的案例中发生了这种情况,因为有一个明显的合并错误,我试图运行应用程序。
通过运行Build→Make Project查看具体的错误。
其他回答
在配置新项目时
公司名称应该以.app结尾。例如,它应该是android.example.com.app 它不应该是android.example.com。
你可能会遗漏<intent_filter>属性。确保在清单文件中包含此活动。
在我的案例中,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.
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"/>