Ask Your Question

build problems for android_binary_package - Eclipse Indigo, Ubuntu 12.04

asked 2012-07-03 15:25:16 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

Following the tutorial at:

*edit* new tutorial is OpenCV 2.4.2 for Android and the updated tutorial in answer below. As per recommendation, a summary of the problems*

Summary of problems building android_binary_package with Eclipse on Ubuntu

  1. Errors following the steps for JDK installation
  2. Errors attempting to build from commandline with Ant and build.xml.
  3. errors for all sample projects. There is a script in /samples/android/ . It seems it is missing a #!/bin/bash and, for me, errors of Command not found android: occur. I needed to give a full path to the android executable in adnroid-sdk-linux/tools/ . I just discovered the script, it's not mentioned in the tutorial.
  4. Not sure how to link OpenCV-2.4.0 Library into Eclipse. Which folder should i reference? One containing .jar or AndroidManifest.xml?

[my comments in []s ]

1 Sun JDK 6 [First of all, I'm surprised if only the Sun JDK works that it isn't mentioned in]

Dependencies: Java 1.6 or higher is required for ADT 20.0.0.

[In fact, i have been using Eclipse Indigo to develop android for a few projects and output from errors in the console say I'm running ]

java.version=1.6.0_24 java.vendor=Sun Microsystems Inc.

but in a terminal shell $ java -version gives

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

[Following the instructions, i run into problems.]

Visit and download installer for your OS.

[requires a long login, must sudo chmod +x the downloaded file, i get errors when i run the file of dependencies not found like /bin/sh but of course they are there. Exits with Done, but i don't know if it was successful or where it unpacked the files to. No easy checkpoint. Command-line output follows]

rpm: RPM should not be used directly install RPM packages, use Alien instead!
rpm: However assuming you know what you are doing...
many errors ending with...
error: Failed dependencies:
    /bin/sh is needed by sun-javadb-core-10.6.2-1.1.i386

[Continuing on with the tutorial]

Here is a detailed installation guide for Ubuntu and Mac OS: (only JDK sections are applicable for OpenCV)

[following their instructions I get problems]

$ sudo add-apt-repository "deb lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'sun-java6-jdk' has no installation candidate

Note OpenJDK is not usable for Android development because Android SDK supports only Sun JDK. If you use Ubuntu, after installation of Sun JDK you should ... (more)

edit retag flag offensive close merge delete



Ok, you posted a long detailed description of your problem, maybe it would help if in the beginning of the post you write the short version clearly stating: problem, question.

Rui Marques gravatar imageRui Marques ( 2012-07-04 04:26:12 -0600 )edit

4 answers

Sort by ยป oldest newest most voted

answered 2012-07-05 08:26:25 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

edit flag offensive delete link more


OpenCV 2.4.2 worked great. The OpenCV Library Manager for android is fantastic. Linking libs is a real weak spot on android development and with the new manager everything was so smooth.

darKoram gravatar imagedarKoram ( 2012-08-03 21:01:01 -0600 )edit

answered 2012-07-05 19:16:04 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

I was able to install the jdk from . Select your flavour of distro. Mine: jdk-6u33-linux-x64.bin

It's possible that my problems installing before were from choosing an "RPM" type package. Instructions on another page indicate that Ubuntu prefers the auto-installer to rpms.

I followed the steps you gave. However, I have some concerns over using update-alternatives as it caused numerous problems in the past. (Changed phython to 3.2 for a project, but it broke nearly everything else in my distro).

It wasn't obvious in Eclipse where to locate the JRE. Selecting File->Build Path->Configure Build Path -> Select libraries tab -> Add Library -> System JRE Library -> Add [ I tried searching all through the /opt/java/64 hierarchy but Eclipse never recognized what it wanted. Finally, clicking on "Search" button instead of "Add" and Eclipse found it automatically.

This didn't clear up my issues in Eclipse however. I tried File->Refresh and Project->Clean. Nope. I tried re-starting Eclipse... but it no longer starts:

[Popup dialog] An error has occurred. See the log file /home/kesten/.eclipse/org.eclipse.platform3.7.0155965261/configuration/1341530909313.log.

[log file] !ENTRY org.eclipse.osgi 4 0 2012-07-05 18:28:30.390 !MESSAGE Application error !STACK 1 java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: no swt-gtk-3740 in java.library.path no swt-gtk in java.library.path Can't load library: /home/kesten/.swt/lib/linux/x8664/ Can't load library: /home/kesten/.swt/lib/linux/x8664/

at org.eclipse.swt.internal.Library.loadLibrary(

libswt-gtk is installed, but it's in my java.library.path for openJDK, not the sun version.

I think I'd prefer a less "invasive" method that switches just the jdk/jre used for the project, rather than switching the whole system which may have unintended consequences. Will play with this idea.

BTW... I did get the commandline "$ ant debug" build working. Reading build.xml is very helpful. Was also able to fix the samples/android/ script to work on my system. Will describe this in another post.

edit flag offensive delete link more

answered 2012-07-07 11:02:31 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

Fixes: 1. Eclipse seems to have an easy tool for selecting JRE within a workspace without changing system settings (via update-alternatives). Right-click project -> Build Path -> Configure Build Path -> click Libraries Tab -> Add Library -> JRE -> Search. You can then browse to the top level install location of your Sun JDK distro and Eclipse will find the files it needs. 2. The OpenCV-2.4.0 package shows no errors or warnings in Eclipse

Problems: 1. All sample projects except OpenCV-2.4.0 (library) have errors due to import org.opencv.<package>
This is despite explicitly including the library in the, AndroidManifest.xml and listing it as a referenced package.

The following shows some of the paths I've tried in my 15-puzzle/ file

# Project target.

# This file lives in OpenCV-2.4.0/samples/android/15-puzzle
# relative path to folder with OpenCV-2.4.0.jar file
# android.library.reference.1=../../../modules/java/android
# relative path to folder with OpenCV-2.4.0 file
# android.library.reference.1=../../../

I'm not sure if android can handle absolute paths to resources, but neither relative nor abs worked for me.

edit flag offensive delete link more

answered 2012-07-04 08:26:13 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

Hi darKoram, maybe you should try to break down your long problem into several smaller ones.

To help you with the java installation part of your long problem:

As you already found out Ubuntu no longer ships with sun-java6-jdk, so you have to install it manually. Below you find the instructions to install jdk6

  1. Download jdk6 from sun/oracle (I am using jdk1.6.0_33)
  2. uncompress the downloaded archive => jdk1.6.0_33
  3. mkdir /opt/java/64/
  4. sudo mv jdk1.6.0_33/ /opt/java/64/
  5. run:
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jdk1.6.0_33/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/64/jdk1.6.0_33/bin/javac" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/64/jdk1.6.0_33/bin/javaws" 1
    sudo update-alternatives --install "/usr/bin/javah" "javah" "/opt/java/64/jdk1.6.0_33/bin/javah" 1

  6. run:
    sudo update-alternatives --config java
    sudo update-alternatives --config javac
    sudo update-alternatives --config javaws
    sudo update-alternatives --config javah

Conerning your OpenCV installation. I would recommend you to use the latest OpenCV version 2.4.1, download the android(!) package, within you find an OpenCV-2.4.1 and an OpenCV-2.4.1-samples folder. Import the OpenCV-2.4.1 folder to Eclipse via File -> Import -> General -> Existing Projects into Workspace. For the samples, OpenCV-2.4.1-samples, you can do the same and choose which samples to install.

edit flag offensive delete link more


Actually the latest OpenCV is now the 2.4.2 :)

Rui Marques gravatar imageRui Marques ( 2012-07-05 03:49:39 -0600 )edit

Question Tools



Asked: 2012-07-03 15:25:16 -0600

Seen: 48,031 times

Last updated: Oct 02 '12