我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
我把IntelliJ IDEA从12.0.4升级到12.10。
现在我的Android项目中的所有模块都给出了错误:
错误:没有找到默认活动
我恢复到12.0.4,一切都恢复正常了。
什么好主意吗?我认为这可能是一个丢失插件的问题。由于插件没有安装,它无法找到默认活动。另一个东西可能是本地配置,但我对此表示怀疑。我删除了配置文件夹来验证,这没有改变任何东西。
当前回答
有时会出现这种错误,因为Android Studio的错误行为,因为内部缓存和项目构建系统。即使我们已经为默认活动完美地设置了一切。
对于这样的问题,我找到了一个解决方案,它是为我工作。
步骤1。Android Studio→菜单文件→无效缓存,关闭Android Studio。
步骤2。进入路径C:\Users\USER.AndroidStudio3.2\system
步骤3。更改名称扩展为下面文件夹的.back
Example: compiler should be *compiler.back*
编译器 compiler-server 转换 external-build_system 框架 gradle resource_folder_cache
步骤4:启动Android Studio并打开项目。
其他回答
编辑文件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>
正确的方法是将以下内容添加到Manifest文件中:
<activity
android:name="FULL_NAME_OF_YOUR_ACTIVITY"
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> </application>
不需要使缓存无效。
好吧,我有时不理解Android Studio……
我遇到了同样的问题,并尝试了这里的答案,但无济于事。
然后我改变了一件事:我的intent-filter中的动作名称全部用大写。我把它改为小,只留下大写的单词MAIN,它解决了这个问题!多么荒谬!
我将Intent-filter改为
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
只需要添加DEFAULT选项。我正在使用Process Phoenix库,它提示我定义一个默认意图。这就解决了我的问题。
前面的答案对我没有任何帮助。过了一段时间,我发现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>