lollercoaster
lollercoaster

Reputation: 16533

Compiling Android .apk on Linux Server

I want to be able to build .apk files programmatically given Android projects (folders, .java, .xml, etc files) with ant on my Ubuntu 10.04 i386 Server. I'm not using Eclipse or even a GUI.

1) I have already followed these instructions: http://source.android.com/source/initializing.html

2) I downloaded/unpacked the Android Linux SDK here: http://developer.android.com/sdk/index.html

3) Now when I navigate to /home/myusername/www/android-sdk-linux_x86/tools and type in ./android I get this error:

myusername@myserver:~/www/android-sdk-linux_x86/tools$ ./android
Starting Android SDK and AVD Manager
No command line parameters provided, launching UI.
See 'android --help' for operations from the command line.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3550 or swt-pi-gtk in swt.library.path, java.library.path or the jar file
    at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    at org.eclipse.swt.internal.gtk.OS.<clinit>(Unknown Source)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
    at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
    at com.android.sdkmanager.Main.showMainWindow(Main.java:297)
    at com.android.sdkmanager.Main.doAction(Main.java:281)
    at com.android.sdkmanager.Main.run(Main.java:99)
    at com.android.sdkmanager.Main.main(Main.java:88)

Any ideas on what is going wrong?

Upvotes: 2

Views: 7316

Answers (4)

axil
axil

Reputation: 797

Thanks to dtmilano I managed to find a solution. First, if not installed, install libswt-gtk-3.5-java if on debian machine, swt if on archlinux. If on a i686 machine, enter in terminal:

export ANDROID_SWT=path-to-android-sdk/tools/lib/x86

If on a x86_64 (you may need some extra 32bit libraries, I dunno)

export ANDROID_SWT=path-to-android-sdk/tools/lib/x86_64

Then android will run. If you want to make this permanent, one simple way is to put the above line to your ~/.bashrc. After login/logout the change will be permanent :)

Upvotes: 1

lollercoaster
lollercoaster

Reputation: 16533

Also - my apologies, I dug a little deeper and found a very similar thread here: "android update sdk" on headless linux

Upvotes: 0

nunaxe
nunaxe

Reputation: 1420

When you run the ./android binary without arguments it tries to open a GUI window.

From the output you presented, it seems that the ./android binary is working great, but since you are running a headless server it crashes.

Here are the command-line steps to build an Android .apk:

  1. android create project --name ExampleProj --activity ExampleProj --path ./ --package com.example.project --target 2
  2. ant debug

This will create an ExampleProj-debug.apk.

A great source of help is the --help argument of the ./android binary, combined with the action you want to take. For instance:

android --help create project

Hope this helps.

Upvotes: 2

Diego Torres Milano
Diego Torres Milano

Reputation: 69396

If you are expecting to run headless android issue some command line options, like --help.

However, if this is not your intention and you want to use your display to show android GUI use ssh -X to enable X11 forwarding, install libswt-gtk-3.5-java and set ANDROID_SWT to /usr/lib/java.

Upvotes: 2

Related Questions