我把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>
其他回答
如果前面答案中的选项不起作用,请尝试删除.gradle文件夹。
我使用的是Android Studio 3.3.1。我所有的项目都很好,但它们突然都停止了工作,说没有活动。即使是全新的项目也出现了同样的错误。
在数小时使缓存无效后,试图修复清单文件。我注意到它与Android X库有一些关系,比如(androidx.core:core-ktx)。在一些项目中,仅仅更新库就可以解决这个问题,但真正有效的方法是删除.gradle文件夹。
去建造。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
}
}
它非常适合我。
我是如何解决这个问题的:我没有与意图启动器声明相关的问题,我甚至尝试手动声明活动,但它仍然不起作用
我还清除了缓存和临时文件夹,但都不起作用。
因为我有几个活动,似乎其中一个活动,我从存储库中有重复的声明:
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。
进入路径C:\Users\YOUR_WINDOW_USER_NAME.AndroidStudio3.3\system
删除“/ cached”文件夹和“/tmp”文件夹。