我把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并打开项目。

其他回答

之前的回答对我没有任何帮助,Android Studio在我之前运行的所有应用程序中都出现了这个问题——所以我知道——这与我的代码无关。

现在我解出来了:

你需要重置Android Studio: 只需转到C:\Users\yourusername\androidStudio3.2(或类似目录)并删除此目录。

这个家伙在他的旧版本的视频中向你展示了如何做到这一点:

如何将Android Studio重置为默认设置?

在我的案例中,AndroidManifest.xml中有一个打印错误,如下所示。删除应用程序标签上方的“o”字母就解决了这个问题。

显然,Android Studio不会检测AndroidMainfest.xml中的类型错误

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

o
<application android:name=".AppName"
             android:allowBackup="false"
             android:icon="@drawable/ic_launcher"
             android:label="@string/app_name"
             android:theme="@android:style/Theme.Light.NoTitleBar">

如果你正在开发一个小部件应用程序,这个解决方案应该适合你:

进入编辑配置 将启动选项设置为Nothing

正确的方法是将以下内容添加到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>

不需要使缓存无效。

TouchBoarder几乎做到了。尽管选择“不启动活动”会导致什么都不启动。

在Android Studio中运行/调试配置→Android应用程序→常规→活动→选择“启动”选项:

选择你的活动。这并没有完全修复预期的行为,而是正确地覆盖它。