我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
当前回答
编辑文件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>
其他回答
在Android Manifest.xml中,像下面这样设置启动活动:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
用Gradle文件同步项目有时是有效的。
要解决这个整体问题,你应该:
退出Android Studio 进入USER文件夹→AndroidStudio→系统→缓存 删除该文件夹 启动Android Studio。
它将重新索引您的文件,这应该工作。
感谢kirtan403的类似问题。
我也得到了这个错误,
错误:没有找到默认活动
嗯,在我的情况下,它是为磨损模块…我不需要一个活动,所以我只是做:
去编辑配置→磨损→启动选项→启动→无。 应用更改。单击OK。 从清单文件中删除默认活动的现有代码。
注意:不要忘记清理项目和同步Gradle文件。
由于这个问题是关于清单的大量问题的“着陆页”,导致没有发现Default Activity,这里还有另一件事要检查是否有此问题。
打开清单并切换到合并清单选项卡。
有时问题与将项目中的所有清单合并为一个有关,这可能导致错误,因此“未找到默认活动”。问题是,据我所知,除了这个合并清单选项卡,这个错误没有显示在任何地方。
例如:在项目minSdkVersion 10中,在build中降低实现的版本。Gradle文件:从25.4.0到25.3.1解决了这个问题。
dependencies {
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:design:25.3.1'
implementation 'com.android.support:mediarouter-v7:25.3.1'
编辑文件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>