我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
当前回答
这是在我的电脑意外重启后发生的。奇怪的是,我没有做任何修改,仍然得到这个错误。
以上这些对我都没有帮助。解决我问题的,是这个。
步骤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
将其作为一个新项目导入。
其他回答
去建造。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
}
}
它非常适合我。
我得到了这个错误,试图运行一个应用程序,没有一个活动(这是一个androidTest项目)。因此,我只需右键单击测试项目,并从上下文菜单中选择Run或Debug。
前面的答案对我没有任何帮助。过了一段时间,我发现IntelliJ IDEA将动作名称改为大写。如:
<intent-filter>
<action android:name="ANDROID.INTENT.ACTION.MAIN"/>
<category android:name="ANDROID.INTENT.CATEGORY.LAUNCHER"/>
</intent-filter>
恢复正常后,IDEA识别出默认活动:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
错误:没有找到默认活动
我是这样解决的:
运行→编辑配置→Android应用程序→*在“启动”编辑框中输入默认活动类的路径。
使缓存失效/重新启动
之后,你的应用程序必须运行!