eclipse 无法连接到虚拟机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8374628/
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
cannot connect to VM
提问by Kat
I made a test class in my android project to check if my database works. But when I want to debug this class it gives me an error: "Cannot connect to VM", in details it says also "Socket operation on nonsocket: configureBlocking". When I try debugging a test class in another project it works and debugging my other classes in the android project also works. Can the problem be that I try to run a normal test on an android project?
我在我的 android 项目中做了一个测试类来检查我的数据库是否工作。但是当我想调试这个类时,它给了我一个错误:“无法连接到 VM”,详细地说它也说“非套接字上的套接字操作:configureBlocking”。当我尝试在另一个项目中调试测试类时,它可以工作,并且在 android 项目中调试我的其他类也可以工作。问题可能是我尝试在 android 项目上运行正常测试吗?
Can someone help me? Thanks!
有人能帮我吗?谢谢!
回答by Rune
You probably figured this out already, but for others who get stuck in this situation, here is my answer. I've had this problem a couple of times myself now, and I finally found out that it's related to
您可能已经想到了这一点,但对于陷入这种情况的其他人,这是我的答案。我自己现在遇到过几次这个问题,我终于发现它与
including a "main" method in your android class files: Don't do it!
Run Configuration in Eclipse: Delete the automatically created application configurations
在你的 android 类文件中包含一个“main”方法: 不要这样做!
在 Eclipse 中运行配置: 删除自动创建的应用程序配置
The following link provides a very good explanation about the problem, the solution, and the reasons: http://independentlyemployed.co.uk/2010/11/16/solved-internal-error-classfileparser-cpp3161/
以下链接很好地解释了问题、解决方案和原因:http: //independentlypaid.co.uk/2010/11/16/solved-internal-error-classfileparser-cpp3161/
回答by YulCheney
It caused by having a "main" method.
Delete/rename the method and then go to the properties of the project.
Click "Run/Debug Settings" and delete the class (it may make eclipse to run the class after being compiled).
它是由具有“主要”方法引起的。
删除/重命名方法,然后转到项目的属性。
单击“运行/调试设置”并删除该类(可能会使 eclipse 编译后运行该类)。
回答by Mark
I had to change the Test Launcher being used.
我不得不更改正在使用的测试启动器。
Run->Debug Configurations->JUnit->*JUnit Test Class*
Choose Select Otherin the bottom left of the settings dialog, next to the menu list.
在设置对话框的左下方,菜单列表旁边,选择“选择其他”。