我把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>
由于这个问题是关于清单的大量问题的“着陆页”,导致没有发现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'
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"/>
之前的回答对我没有任何帮助,Android Studio在我之前运行的所有应用程序中都出现了这个问题——所以我知道——这与我的代码无关。
现在我解出来了:
你需要重置Android Studio: 只需转到C:\Users\yourusername\androidStudio3.2(或类似目录)并删除此目录。
这个家伙在他的旧版本的视频中向你展示了如何做到这一点:
如何将Android Studio重置为默认设置?
检查舱单上的所有行。
在我的例子中,我犯了这样的错误:
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
LogCat里什么都没有。