eclipse “Hello Android”教程的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2763395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Issue with 'Hello Android' tutorial
提问by Mike Needham
I am brand new to Eclipse and Android, but somewhat familiar with Java. That having been said, I tried to follow the 'Hello Android' tutorial from the developer site using the latest Eclipse (Galieo) and the 2.1 Android SDK, I am on a Macintosh running Snow Leopard (OS X 10.6). I have a default virtual device (though my target is actually for phones like my own HTC Incredible which has the snapdragon processor and of course all the latest accoutrement in smart phones).
我是 Eclipse 和 Android 的新手,但对 Java 有点熟悉。话虽如此,我尝试使用最新的 Eclipse (Galieo) 和 2.1 Android SDK 来遵循开发人员站点上的“Hello Android”教程,我使用的是运行 Snow Leopard (OS X 10.6) 的 Macintosh。我有一个默认的虚拟设备(虽然我的目标实际上是像我自己的 HTC Incredible 这样的手机,它有骁龙处理器,当然还有智能手机中的所有最新装备)。
Everything seemed to go okay until I went to RUN>RUN
and then selected 'Android Application'. My computer spins its wheels for a while and then I see two errors. I have pasted the output from Eclipse below:
一切似乎都很顺利,直到我去RUN>RUN
然后选择了“Android 应用程序”。我的电脑转动了一会儿,然后我看到了两个错误。我在下面粘贴了 Eclipse 的输出:
[2010-05-04 01:53:46 - HelloAndroid] ------------------------------
[2010-05-04 01:53:46 - HelloAndroid] Android Launch!
[2010-05-04 01:53:46 - HelloAndroid] adb is running normally.
[2010-05-04 01:53:46 - HelloAndroid] Performing com.example.helloandroid.HelloAndroid activity launch
[2010-05-04 01:53:46 - HelloAndroid] Automatic Target Mode: launching new emulator with compatible AVD 'myAVD'
[2010-05-04 01:53:46 - HelloAndroid] Launching a new emulator with Virtual Device 'myAVD'
[2010-05-04 01:53:58 - HelloAndroid] New emulator found: emulator-5554
[2010-05-04 01:53:58 - HelloAndroid] Waiting for HOME ('android.process.acore') to be launched...
[2010-05-04 01:53:59 - Emulator] 2010-05-04 01:53:59.501 emulator[10398:903] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
[2010-05-04 01:54:23 - HelloAndroid] emulator-5554 disconnected! Cancelling 'com.example.helloandroid.HelloAndroid activity launch'!
I never do see the text in the emulator and the emulator crashes with a message about it quitting unexpectedly.
我从来没有看到模拟器中的文本,模拟器崩溃并显示一条关于它意外退出的消息。
The crash report states:
崩溃报告指出:
Process: emulator [10472]
Path: /Applications/android-sdk-mac_86/tools/emulator
Identifier: emulator
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: eclipse [10468]
Date/Time: 2010-05-04 02:25:41.153 -0500
OS Version: Mac OS X 10.6.3 (10D573)
Report Version: 6
Interval Since Last Report: 2558914 sec
Crashes Since Last Report: 4
Per-App Crashes Since Last Report: 2
Anonymous UUID: C5F178C1-5290-4CA9-AD6E-E9C4F5582754
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000001fd2f000
Crashed Thread: 3
NOTE: Running the emulator from the command line with:
注意:从命令行运行模拟器:
iainnitro-Mac:tools iainnitro$ ./emulator -avd myAVD
2010-05-04 02:49:23.011 emulator[10556:903] Warning once: This application, or a library it
uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw
and move to Quartz.
Segmentation fault
iainnitro-Mac:tools iainnitro$
yields a segmentation fault(as noted above from the terminal output). So the emulator is dying on its own before anything can be shown.
产生分段错误(如上所述从终端输出)。所以模拟器在任何东西都可以显示之前就自行消亡了。
I have tried restarting the ADB processes.
我尝试重新启动 ADB 进程。
The actual code is line by line from the tutorial and I have never been able to get to the XML part yet.
实际代码是教程中的一行一行代码,我还从来没有接触过 XML 部分。
I am not sure what is wrong with my environment setup or if it is just an incompatibility with Snow Leopard? I would REALLY appreciate any help in resolving this as I am very interested in developing on this platform.
我不确定我的环境设置有什么问题,还是只是与 Snow Leopard 不兼容?我真的很感激解决这个问题的任何帮助,因为我对在这个平台上开发非常感兴趣。
Thank-you,
谢谢,
Mike N Lawrence, Kansas
迈克·劳伦斯 (Mike N Lawrence),堪萨斯州
回答by VonC
No direct experience, but this seems to be a recurrent issue:
没有直接经验,但这似乎是一个反复出现的问题:
This threadsuggests:
该线程建议:
You haven't let the emulator boot all the way up. Start it then wait until you see a desktop, just like on a real phone.
你还没有让模拟器一直启动。启动它,然后等到您看到桌面,就像在真正的手机上一样。
This onementions (I suspect point 1. is not a concern for you):
这个提到(我怀疑第 1 点不是你关心的问题):
Get more RAM. I was running on 256 MB (which I believe is below minimum requirements), just upgraded today to 1024 MB (long time coming), application now starts fine. Although I still do see some error messages in the emulator, they don't seem to actually do anything.
Install from command line. This is a bit laborius, but you can launch an emulator from the command line (assuming
<android sdk path>\tools
is added to your PATH variable) just type emulator, then browse to the location ofyour_app_here.apk
, and execute
获得更多内存。我在 256 MB 上运行(我认为低于最低要求),今天刚刚升级到 1024 MB(很长一段时间),应用程序现在可以正常启动。虽然我仍然在模拟器中看到一些错误消息,但它们似乎实际上并没有做任何事情。
从命令行安装。这有点费力,但您可以从命令行启动模拟器(假设
<android sdk path>\tools
已添加到您的 PATH 变量中)只需键入 emulator,然后浏览到 的位置your_app_here.apk
,然后执行
adb install your_app_here.apk
If you launch the emulator from Eclipse, execute
adb kill-service
and thenadb start-service
first (orkill-server
/start-server
. not sure the exact commands). Then your app will be installed on the emulator.
如果您从 Eclipse 启动模拟器,请先执行
adb kill-service
然后执行adb start-service
(或kill-server
/start-server
. 不确定确切的命令)。然后您的应用程序将安装在模拟器上。
Also (a bit old but might still be relevant)
另外(有点旧但可能仍然相关)
Maybe the emulator is running so slow, and the adb server, or another component like "DDMS" is a little "desperate" because seems it's waiting to the emulator to iniatialize the some
HOME
aplication.
But the emulator is running slow, the console in Eclipse send a message:emulator-5554 disconnected! Cancelling 'com.android.hello.HelloAndroid' launch!;
and the emulator continues running normally and boot it's system, but don't run application that I build.So for that problem I run program, and when the emulator is opened, I go back to eclipse in DDMS Perspective and in the Device tab y press a button "
restart adb server
" before the console shows me the message of "emulator-5554 disconnected!
".
I do it several times until the emulator finally boot the OS.
After booted the OS on the emulator, eclipse don't send that disconnect error, and "sends" the app that I've built, also the console shows messages about this.
Then finally appears on the mobile "Hello, Android".
也许模拟器运行速度很慢,并且 adb 服务器或其他组件(如“DDMS”)有点“绝望”,因为它似乎正在等待模拟器初始化某些
HOME
应用程序。
但是模拟器运行缓慢,Eclipse 中的控制台发送一条消息:emulator-5554 disconnected! Cancelling 'com.android.hello.HelloAndroid' launch!;
模拟器继续正常运行并启动它的系统,但不运行我构建的应用程序。所以对于那个问题,我运行程序,当模拟器打开时,我回到 DDMS Perspective 中的 eclipse 并在 Device 选项卡中按下按钮“
restart adb server
”,然后控制台向我显示“emulator-5554 disconnected!
”的消息。
我做了几次,直到模拟器最终启动操作系统。
在模拟器上启动操作系统后,eclipse 不会发送该断开连接错误,并“发送”我构建的应用程序,控制台也会显示有关此的消息。
然后终于出现在手机上“你好,Android”。
回答by Ravi Vyas
There has been a discussion on this with two proposed solutions http://code.google.com/p/android/issues/detail?id=724
有两个提议的解决方案对此进行了讨论 http://code.google.com/p/android/issues/detail?id=724
Comment 17 by zachrcrowe, Jan 06, 2010FYI - I had to change a line in the Hello Android example to read this.setContentView(tv); in order for it to work. As mentioned above, the deprecation warning shouldn't affect the functionality of the emulator.
zachrcrowe 发表的评论 17,2010 年 1 月 6 日仅供参考 - 我必须更改 Hello Android 示例中的一行才能阅读 this.setContentView(tv); 为了让它工作。如上所述,弃用警告不应影响模拟器的功能。
Comment 18 by mfrony, Jan 14, 2010I had the same problem when I ran the Hello Android example. The way I solved it and could run my first Android code was by changing the Project Build Target from 1.1 to 1.5.
评论 18 by mfrony,2010 年 1 月 14 日我在运行 Hello Android 示例时遇到了同样的问题。我解决它并运行我的第一个 Android 代码的方法是将项目构建目标从 1.1 更改为 1.5。
回答by bebeastie
This seems to be a timing issue. For some reason Eclipse attempts to load the application on to the emulator before it is "ready". I'm not sure why this occurs but I did find a work around: just start the emulator from the command line before you run the application.
这似乎是一个时间问题。出于某种原因,Eclipse 会尝试在应用程序“准备好”之前将其加载到模拟器上。我不确定为什么会发生这种情况,但我确实找到了解决方法:只需在运行应用程序之前从命令行启动模拟器。
- Start clean by closing Eclipse (maybe the OP didn't exit Eclipse before he tried to run via the command line?)
Start the emulator via Terminal by navigating to the android-sdk-mac_86/toolsdirectory and typing:
./emulator -avd my_avd
Open Eclipse and attempt to run the tutorial again using the same steps as before
- A dialog box should open asking whether you would like to start a new AVD or use the one that is already running--choose to use the one that is already running.
- 通过关闭 Eclipse 开始清理(也许 OP 在尝试通过命令行运行之前没有退出 Eclipse?)
通过导航到android-sdk-mac_86/tools目录并键入以下内容,通过终端启动模拟器:
./emulator -avd my_avd
打开 Eclipse 并尝试使用与之前相同的步骤再次运行本教程
- 应该会打开一个对话框,询问您是要启动一个新的 AVD 还是使用已经在运行的 AVD——选择使用已经在运行的那个。
回答by infinitloop
what i did was to move the circle that appears when the AVD launches to the unlock position, and there it was 'Hello, Android'!
我所做的是将 AVD 启动时出现的圆圈移动到解锁位置,然后是“你好,Android”!
回答by Scuba
This worked on Linux for me:
这对我来说适用于 Linux:
- Run Emulator (Wait for the home screen of the Emulator to load)
- Click Window > Open Perspective > DDMS
- In Devices Panel, click on drop down menu > Reset adb
- Run project
- 运行模拟器(等待模拟器的主屏幕加载)
- 单击窗口 > 打开透视图 > DDMS
- 在设备面板中,单击下拉菜单 > 重置 adb
- 运行项目
回答by Rajesh
I had this same problem when I tried to run the emulator using a 4.0 AVD. It used to crash at the bootup screen and show 'Segmentation fault' in the console. I was able to fix it by increasing the SD card size of the AVD to 1GB from 32MB.
当我尝试使用 4.0 AVD 运行模拟器时,我遇到了同样的问题。它曾经在启动屏幕上崩溃并在控制台中显示“分段错误”。我能够通过将 AVD 的 SD 卡大小从 32MB 增加到 1GB 来修复它。
回答by Mike Needham
For whatever reason, I stopped getting the segmentation fault when I added:
无论出于何种原因,当我添加以下内容时,我不再出现分段错误:
this.setContentView(tv);
the 'this' seemingly solved the issue. The seg fault happens if you try to run the emulator without any .apk file I assume. (I was getting that from the command line as well). I hope the tutorial will be updated.
'this'似乎解决了这个问题。如果您尝试在没有我假设的任何 .apk 文件的情况下运行模拟器,则会发生 seg 错误。(我也是从命令行得到的)。希望教程能更新。