简体   繁体   English

Android 应用程序未显示在模拟器中

[英]Android app not showing in the emulator

I installed eclipse, android sdk, created AVD (tried with different versions), then created simple hello world program (autogenerated).我安装了 eclipse,android sdk,创建了 AVD(尝试了不同的版本),然后创建了简单的 hello world 程序(自动生成)。

When I run it, it supposed to load up and show helloworld screen... but nothing happens.当我运行它时,它应该加载并显示 helloworld 屏幕......但没有任何反应。 Emulator just loads up and shows android main screen.模拟器只是加载并显示 android 主屏幕。 My app is nowhere to be seen.我的应用程序无处可见。

Log:日志:

[2012-05-19 19:09:34 - GameTest] Android Launch!
[2012-05-19 19:09:34 - GameTest] adb is running normally.
[2012-05-19 19:09:34 - GameTest] Performing org.test.game1.GameTestActivity activity launch
[2012-05-19 19:09:34 - GameTest] Automatic Target Mode: launching new emulator with compatible AVD 'def_avd'
[2012-05-19 19:09:34 - GameTest] Launching a new emulator with Virtual Device 'def_avd'

And that's it...就是这样......

What is wrong and how can I actually load up my program?出了什么问题,我如何才能真正加载我的程序?

Some clarifications: I tried to run emulator beforehand, and then running my app.一些澄清:我试图事先运行模拟器,然后运行我的应用程序。 I tried running emulator directly from eclipse "Run as - Android application" but still the same exact thing.我尝试直接从 Eclipse “Run as - Android application”运行模拟器,但仍然完全相同。

The thing missing is given below XML snippet in your AndroidManifest.xml缺少的东西在您的AndroidManifest.xml中的 XML 片段下方给出

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Add this tag in your xml under activity tag, then your application will be launched on your Emulator在活动标记下的 xml 中添加此标记,然后您的应用程序将在您的模拟器上启动

Unfortunately nothing suggested in other replies helped, but I found a decent workaround.不幸的是,其他回复中的任何建议都没有帮助,但我找到了一个不错的解决方法。

If you have an android device probably the simplest thing to do would be to connect it to usb and just hit "debug as android application" and in 3 or 4 seconds it will load up on your android device.如果您有一个 android 设备,最简单的方法可能是将它连接到 USB 并点击“调试为 android 应用程序”,然后在 3 或 4 秒内它就会加载到您的 android 设备上。

To use that option you need to instal USB driver package, but that is no problem.要使用该选项,您需要安装 USB 驱动程序包,但这没问题。

clean the projects and refresh the emulator.清理项目并刷新模拟器。

Other wise create new emulator and run it.否则明智地创建新的模拟器并运行它。

close the emulator and adb in windows task manager and关闭 Windows 任务管理器中的模拟器和 adb 并

then try to create new emulator and run it.然后尝试创建新的模拟器并运行它。

Try this, first open the avd manager and launch the emulator, and wait until the emulator boots and android home screen shows up.试试这个,首先打开 avd 管理器并启动模拟器,然后等待模拟器启动并显示 android 主屏幕。 Now try running the program.现在尝试运行该程序。

I know this is an old question but I just had the same issue so here is how I fixed it in Android Studio 2.1.我知道这是一个老问题,但我遇到了同样的问题,所以这是我在 Android Studio 2.1 中修复它的方法。

In the Run configuration I had it set to start the AVD that I wanted automatically, and it would always start another AVD and none of them would have the app.在“运行”配置中,我将其设置为自动启动我想要的 AVD,并且它始终会启动另一个 AVD,并且没有人拥有该应用程序。 So, I set the configuration to "Show Device Choose Dialog", started the AVD manually, and then when I hit Run I selected the running AVD and it popped right up.因此,我将配置设置为“显示设备选择对话框”,手动启动 AVD,然后当我点击运行时,我选择了正在运行的 AVD,它立即弹出。 I hope it works for you too!我希望它也适用于你!

Also, I had set the Launch Option to start my main activity explicitly, and then I turned it back to default and it still worked after changing to default.此外,我已将 Launch Option 设置为显式启动我的主要活动,然后我将其恢复为默认值,并且在更改为默认值后它仍然有效。 So if it doesn't work for you the first time maybe try doing that too.因此,如果它第一次对您不起作用,也可以尝试这样做。

I had same issue when I was having one intent-filter for all the options, then I separated into 2 intent-filters, app started showing up当我为所有选项设置一个意图过滤器时,我遇到了同样的问题,然后我分成了 2 个意图过滤器,应用程序开始出现

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
             android:host="java-lang-programming"
             android:scheme="android-app-google-plus-demo" />
    </intent-filter>

Several things you might try :您可能会尝试几件事:

  • Make sure the emulator build version is the same as code确保模拟器构建版本与代码相同
  • Try and do :尝试做:

     > adb kill-server > adb start-server
  • Restart Eclipse?重启 Eclipse?

  • Check out This question and follow the answer guide.查看问题并按照答案指南进行操作。

  • Similar question Here , And Here check it out类似的问题在这里在这里检查一下

Be sure to click "Use Host GPU" on Virtual Device Screen and then start your device.请务必在虚拟设备屏幕上单击“使用主机 GPU”,然后启动您的设备。 Wait until UI of the device is loaded.等待设备的 UI 加载完毕。

只需一次检查构建路径并支持 android 库和 android 模拟器版本和应用程序支持版本和所有

I tried to fix it myself, but nothing seemed to be working,我试图自己修复它,但似乎没有任何效果,

So I just:所以我只是:

  1. Re-installed Visual Studio重新安装 Visual Studio
  2. Reset my phone to factory default将我的手机重置为出厂默认设置
  3. Went through the quick process of enabling USB Debugging ( Settings > About phone > Software information > Tap Build number seven times to enable Developer options > Go to Developer options (which is just below About phone in the Settings > Search for USB Debugging and enable it)完成了启用 USB 调试的快速过程(设置>关于手机>软件信息> 点击内部版本号七次以启用开发人员选项 > 转到开发人员选项(就在设置 > 搜索USB 调试中的关于手机下方并启用它) )
  4. Then I plugged in my phone again, and after installing USB driver package like NewProger suggested, I followed the usual steps to setting up my phone as an Android Emulator.然后我再次插入我的手机,在安装了NewProger建议的USB 驱动程序包后,我按照通常的步骤将我的手机设置为 Android 模拟器。

And it's working just fine now.它现在工作得很好。

I can't exactly pinpoint what did it for me, but I guess there's no harm in trying all four steps, as a last resort, after backing up necessary files, and what not.我不能确切地指出它对我做了什么,但我想在备份必要的文件之后尝试所有四个步骤并没有什么坏处,作为最后的手段,什么不是。

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM