[英]android: Exception in org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
I'm trying to setup an environment in which I can develop android apps on an Ubuntu server 13.04.我正在尝试设置一个可以在 Ubuntu服务器13.04 上开发 android 应用程序的环境。 Therefore, I can only use the command line.
因此,我只能使用命令行。
When I run android
, just to check if it's working, I get:当我运行
android
,只是为了检查它是否正常工作,我得到:
Exception in thread "main" org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.widgets.Display.createDisplay(Unknown Source)
at org.eclipse.swt.widgets.Display.create(Unknown Source)
at org.eclipse.swt.graphics.Device.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.getDefault(Unknown Source)
at org.eclipse.swt.widgets.Shell.<init>(Unknown Source)
at org.eclipse.swt.widgets.Shell.<init>(Unknown Source)
at com.android.sdkuilib.internal.repository.ui.SdkUpdaterWindowImpl2.createShell(SdkUpdaterWindowImpl2.java:168)
at com.android.sdkuilib.internal.repository.ui.SdkUpdaterWindowImpl2.open(SdkUpdaterWindowImpl2.java:137)
at com.android.sdkuilib.repository.SdkUpdaterWindow.open(SdkUpdaterWindow.java:111)
at com.android.sdkmanager.Main.showSdkManagerWindow(Main.java:356)
at com.android.sdkmanager.Main.doAction(Main.java:334)
at com.android.sdkmanager.Main.run(Main.java:120)
at com.android.sdkmanager.Main.main(Main.java:103)
What I've done so far:到目前为止我所做的:
apt-get install ant
/home/camilstaps
/home/camilstaps
到我的主目录/home/camilstaps
/home/camilstaps/adt-bundle-linux/tools
to my PATH
environment variable/home/camilstaps/adt-bundle-linux/tools
到我的PATH
环境变量中What can I do to solve this exception?我能做些什么来解决这个异常?
您可以使用-u
(无 UI)选项从命令行更新 sdk。
./android update sdk -u
The problem here was that android
tried to open a graphical display, which it couldn't.这里的问题是
android
试图打开一个图形显示,但它不能。 android
simply cannot be runned on a server without a graphical screen. android
根本无法在没有图形屏幕的服务器上运行。
However, with some parameters, android
can be used.但是,通过一些参数,可以使用
android
。 For example, see here :例如,请参见此处:
android create project \
--target <target_ID> \
--name <your_project_name> \
--path path/to/your/project \
--activity <your_activity_name> \
--package <your_package_namespace>
If you want to run the Android IDE (which is Eclipse), you're going to need an X server to display it on.如果您想运行 Android IDE(即 Eclipse),您将需要一个 X 服务器来显示它。 I'd recommend not trying to develop Android apps on a headless server, as you're going to need a display to use the IDE, and to run your app in the emulator, so that you can test it without flashing it to a device every time you change something.
我建议不要尝试在无头服务器上开发 Android 应用程序,因为您将需要一个显示器来使用 IDE 并在模拟器中运行您的应用程序,以便您可以在不将其刷入设备的情况下对其进行测试每次你改变一些东西。
If you want to develop the app without an X display, you're going to have to do everything by hand, which the IDE would normally do for you, and use an editor which doesn't require X, such as vim
or emacs
.如果您想开发没有 X 显示的应用程序,您将不得不手动完成所有工作,IDE 通常会为您完成这些工作,并使用不需要 X 的编辑器,例如
vim
或emacs
。
If you ssh -X in to the box and start android, it should use xserver on your machine.如果你 ssh -X 进入盒子并启动 android,它应该在你的机器上使用 xserver。 Sometimes I have to start another application eg Firefox to get the X working before I start android.
有时我必须先启动另一个应用程序,例如 Firefox,才能在启动 android 之前使 X 工作。
It looks like an old eclipse bug.它看起来像一个旧的日食错误。 It was related the JavaVM, you could try another VM if you can exclude that the issue is related to the X environment.
它与JavaVM有关,如果您可以排除该问题与X环境有关,则可以尝试另一个VM。
In My case, I tried to install GTK packages (using 'sudo apt-get install') ,still error was coming repeatedly.就我而言,我尝试安装 GTK 软件包(使用“sudo apt-get install”),但错误仍然反复出现。
To identify error , Please check log path : /configuration/*.log要识别错误,请检查日志路径:/configuration/*.log
you will notice the stack trace present in error log emphasizes about display related issue.您会注意到错误日志中存在的堆栈跟踪强调了与显示相关的问题。 Eclipse requires X server to be started so that User Interface loads properly.
Eclipse 需要启动 X 服务器才能正确加载用户界面。 Root user by default doesn't start X-server.
默认情况下,root 用户不会启动 X-server。
Hence I switched to another user and was able to open eclipse successfully.因此我切换到另一个用户并且能够成功打开eclipse。
root@anotheruser:/eclipse/configuration# exit
logout
anotheruser@anotheruser:~$ cd /eclipse/
anotheruser@anotheruser:/eclipse$ ./eclipse
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.