You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android模拟器运行无预期结果,仅显示手机主菜单问题求助

问题分析与解决方案

你的核心问题出在AndroidManifest.xml的配置上,存在两个关键错误:

  1. 重复声明同一Activity
    你在清单文件里重复注册了两次LoginActivity,这会导致系统解析配置时出现冲突,无法正确识别应用的启动逻辑。

  2. 多个Activity设置启动入口
    RegisterActivity与两次LoginActivity都添加了<action android:name="android.intent.action.MAIN" />和<category android:name="android.intent.category.LAUNCHER" />的intent-filter。这种配置会让系统无法确定应用启动时应打开哪个页面,最终导致应用无法正常启动,模拟器停留在主屏幕。

修正后的AndroidManifest.xml

删除重复的LoginActivity声明,且仅给一个Activity设置启动入口(通常为登录页),修正后的代码如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.TATTOFOUNDLER"
        tools:targetApi="31">
        <!-- 仅给LoginActivity设置启动入口 -->
        <activity
            android:theme="@style/LoginPage"
            android:windowSoftInputMode="adjustResize"
            android:name=".LoginActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- RegisterActivity移除启动入口的intent-filter -->
        <activity
            android:name=".RegisterActivity"
            android:exported="true">
        </activity>
    </application>

</manifest>

后续操作步骤

  • 清理项目构建缓存:点击Android Studio顶部菜单栏的Build -> Clean Project,再执行Rebuild Project
  • 卸载模拟器上的旧应用:打开模拟器应用列表,找到你的应用卸载后重新运行

完成上述操作后,系统就能明确识别应用的启动页面,模拟器应能正常加载你的布局。

内容的提问来源于stack exchange,提问作者Charon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 23:08:16