ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Running rosjava node on an android device - crashes

asked 2012-02-04 20:50:07 -0500

svepe gravatar image

updated 2014-01-28 17:11:16 -0500

ngrennan gravatar image

I am trying to write a node that is supposed to run on an android device. Here is the code I have; basically I want to create a node when a button is clicked (I know it is not a good idea to do it on the UI thread, but this is just for testing purposes). The node itself extends MainNode and publishes a string to a topic.

Button send_btn;
TalkerNode node;
NodeMainExecutor exec;

public void onCreate(Bundle savedInstanceState) {

    send_btn = (Button)findViewById(;
    send_btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v)
            String masterUri = "";
            URI uri;
            NodeConfiguration node_conf;
                uri = new URI(masterUri);
                String host = InetAddressFactory.newNonLoopback().getHostAddress();
                node_conf = NodeConfiguration.newPublic(host);
            catch (URISyntaxException e) 
            node = new TalkerNode();

            exec = DefaultNodeMainExecutor.newDefault();
            exec.execute(node, node_conf);

Everything compiles, the program on the device starts, but it crashes at the line:

String host = InetAddressFactory.newNonLoopback().getHostAddress();

with error - NoClassDefFoundError for the class Moreover, I tried to set the host manually as the ip of the device, but then the program crashes on the next line:

node_conf = NodeConfiguration.newPublic(host);

with error - NoClassDefFoundError for the class I tried importing*, but it didn't help. Any clue how I can fix it? I am using android API level 10 and have pulled rosjava from the repository yesterday.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2012-02-04 22:11:33 -0500

svepe gravatar image

I found out that I need guava, so I have just put it and this solved the problem, but now I am getting SocketException at the same line.

edit flag offensive delete link more

answered 2012-02-06 10:10:52 -0500

selliott gravatar image

I'm not sure if this will help, but here's an example of how I'm currently creating a node using DefaultNodeFactory with the newest rosjava:

NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); 
node = new DefaultNodeFactory(nodeMainExecutor.getScheduledExecutorService()).newNode(config);
edit flag offensive delete link more


It still crashes... I guess I will have to wait a bit until they write up some documentation.
svepe gravatar image svepe  ( 2012-02-07 06:17:28 -0500 )edit

Have you also updated your appmanandroid library? Parts of that library were updated to match with the newest rosjava. Wthout actually seeing your errors, I'd say that outdated appmanandroid parts could cause errors with NodeRunner and DefaultNodeFactory.

selliott gravatar image selliott  ( 2012-02-17 10:27:58 -0500 )edit

answered 2012-02-05 01:46:59 -0500

svepe gravatar image

So solved the problem by setting the host name to the IP of the device, but now the TalkerNode crashes. I tried different ways to create a node but all examples seem to be outdated with the NodeRunner and the DefaultNodeFactory. Are there any examples for the new structure of rosjava?

edit flag offensive delete link more


If you build rosjava_core and android_core from source, all of the examples (*_tutorial packages) are up to date.

damonkohler gravatar image damonkohler  ( 2012-02-23 03:35:39 -0500 )edit

Question Tools


Asked: 2012-02-04 20:50:07 -0500

Seen: 1,170 times

Last updated: Feb 06 '12