我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
当前回答
虽然很丑,但对我很管用:
我有这个错误消息,我的问题是在一个模块。我只是删除了应用程序标签完全从我的模块的清单和它工作。
(同时从模块库中删除ic_launcher。)
它是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mymodule"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity
android:name="com.example.mymodule.MainActivity"
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>
</manifest>
Now:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mymodule"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23"/>
</manifest>
其他回答
尝试右键单击项目并选择打开模块设置。然后转到模块中的Sources选项卡,找到src文件夹,右键单击并将其标记为Sources(蓝色)。
在Android Studio的后期版本中没有源代码选项卡,但您可以编辑构建。如何在Android Studio中添加一个链接源文件夹?
在Android Studio中运行/调试配置-> Android应用程序->通用->活动->选择“不启动活动”选项。
我也遇到过同样的问题。由于某些原因,Android Studio将大部分XML文件中的所有Android:name属性(包括manifest)替换为Android:subject (Android Studio无法识别)。
正如你在上图中看到的,IDE不识别android:subject属性。因此,它将无法读取指定mainactivity的行。
解决方案是简单地改变每个android:受制于android:name,然后从Build菜单中重建项目*→重建项目。在重新构建项目时,您可能会遇到相同的问题,因此执行与上面相同的操作。
只是清理和重建。问题就会消失。
编辑文件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>