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;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
send_btn = (Button)findViewById(R.id.send_button);
send_btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
send_btn.setText(R.string.sending);
String masterUri = "http://192.168.1.35:11311";
URI uri;
NodeConfiguration node_conf;
try
{
uri = new URI(masterUri);
String host = InetAddressFactory.newNonLoopback().getHostAddress();
node_conf = NodeConfiguration.newPublic(host);
node_conf.setNodeName("android_node");
node_conf.setMasterUri(uri);
}
catch (URISyntaxException e)
{
e.printStackTrace();
return;
}
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 com.google.common.collect.Lists. 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 com.google.common.base.Preconditions. I tried importing com.google.common.*, 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.
Originally posted by svepe on ROS Answers with karma: 36 on 2012-02-04
Post score: 0