I'm trying to setup an environment in which I can develop android apps on an Ubuntu server 13.04. Therefore, I can only use the command line.

When I run android, just to check if it's working, I get:

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
  • Downloaded the "ADT bundle" from http://developer.android.com/sdk/index.html
  • Unpacked it in my home directory /home/camilstaps
  • Added /home/camilstaps/adt-bundle-linux/tools to my PATH environment variable

What can I do to solve this exception?

share|improve this question

migrated from askubuntu.com Jun 10 '13 at 19:32

This question came from our site for Ubuntu users and developers.

    
Also related (not to exception encountered, but additional details on installing from command line): stackoverflow.com/questions/10941549/… – CJBS Oct 31 '14 at 21:20

You can update the sdk from command line by using the -u (no UI) option.

./android update sdk -u
share|improve this answer
1  
that command blindly installs EVERYTHING ... How to update just what's installed ? – Scott Stensland Feb 11 '17 at 22:44
up vote 5 down vote accepted

The problem here was that android tried to open a graphical display, which it couldn't. android simply cannot be runned on a server without a graphical screen.

However, with some parameters, android can be used. 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>
share|improve this answer
    
noticed the same behavior, when running it as su username (which has no session with the GDM and therefore no DISPLAY under X). could imagine, it might still work - while assigning the display for output, before running ./android. – Martin Zeitler Mar 4 '17 at 6:28
    
@syslogic you could try to use sudo -E -u username, then you keep your own environment. – Keelan Mar 4 '17 at 7:39
    
think that export DISPLAY=:0 or export DISPLAY=:0.0 should select the first available display, while there is any ongoing X11 (gdm) session. one can also select VNC displays like that, when running headless. – Martin Zeitler Mar 5 '17 at 6:31
    
the answer here explains how to authenticate the display: unix.stackexchange.com/a/180585/110101; the condition ForwardX11 yes should also be relevant, to obtain any valid display for output... just noticed, that the ./android command had been obsoleted meanwhile, it's tools/bin/sdkmanager now. – Martin Zeitler Mar 5 '17 at 6:41
    
@syslogic hmm, then it seems you want to do something else than what this question is about. I wanted to use the android command without GUI. – Keelan Mar 5 '17 at 8:05

If you want to run the Android IDE (which is Eclipse), you're going to need an X server to display it on. 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.

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.

share|improve this answer
    
Thanks for the advice! In the end I won't really develop apps on the server, I only want to build them there, sometimes. – Keelan Jun 10 '13 at 14:49

If you ssh -X in to the box and start android, it should use xserver on your machine. Sometimes I have to start another application e.g. Firefox to get the X working before I start android.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.