Ask Your Question
0

Error in main.xml: could not find org.ros.android.views.RosTextView

asked 2011-11-23 08:09:16 -0500

Bei gravatar image

updated 2014-01-28 17:10:51 -0500

ngrennan gravatar image

Hi All,

I have the rosandroid pubsub tutorial installed in Eclipse and am trying to run it on my android phone. I was able to download the rosandroid sdk (android_gingerbread) and import the class files under android_gingerbread/bin/classes. So the project isn't giving me any error compiling it, but the main.xml is giving me this error:

The following classes could not be found:
- org.ros.android.views.RosTextView (Fix Build Path, Edit XML, Create Class)

Although I already have org.ros.android.views.RosTextView in my Build Path. Here's my pubsub MainActivity.java:

/*
 * Copyright (C) 2011 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.ros.android.tutorial.pubsub;

import android.app.Activity;
import android.os.Bundle;
import org.ros.RosCore;
import org.ros.android.MessageCallable;
import org.ros.android.views.RosTextView;
import org.ros.node.DefaultNodeRunner;
import org.ros.node.NodeConfiguration;
import org.ros.node.NodeRunner;
import org.ros.tutorials.pubsub.R;
import org.ros.tutorials.pubsub.Talker;

/**
 * @author damonkohler@google.com (Damon Kohler)
 */
public class MainActivity extends Activity {

  private final NodeRunner nodeRunner;

  private RosCore rosCore;
  private RosTextView<org.ros.message.std_msgs.String> rosTextView;
  private Talker talker;

  public MainActivity() {
    nodeRunner = DefaultNodeRunner.newDefault();
  }

  @SuppressWarnings("unchecked")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    rosTextView = (RosTextView<org.ros.message.std_msgs.String>) findViewById(R.id.text);
    rosTextView.setTopicName("/chatter");
    rosTextView.setMessageType("std_msgs/String");
    rosTextView
        .setMessageToStringCallable(new MessageCallable<String, org.ros.message.std_msgs.String>() {
          @Override
          public String call(org.ros.message.std_msgs.String message) {
            return message.data;
          }
        });
  }

  @Override
  protected void onResume() {
    super.onResume();
    try {
      rosCore = RosCore.newPrivate();
      rosCore.start();
      rosCore.awaitStart();
      NodeConfiguration nodeConfiguration = NodeConfiguration.newPrivate();
      System.out.println(rosCore.getUri());
      nodeConfiguration.setMasterUri(rosCore.getUri());
      talker = new Talker();
      nodeRunner.run(talker, nodeConfiguration);
      nodeRunner.run(rosTextView, nodeConfiguration);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  @Override
  protected void onPause() {
    super.onPause();
    nodeRunner.shutdown();
    rosCore.shutdown();
  }

}

I am very new to android programming and ros. Could anyone help me with this? Thank you so much in advance!!!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2011-12-29 02:21:11 -0500

gopinath gravatar image

You should fully qualify RosTextView in your main.xml something like this

<org.ros.android.views.RosTextView
    class="org.ros.android.views.RosTextView"
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     />

This should fix the problem

edit flag offensive delete link more
0

answered 2011-11-27 04:30:28 -0500

Bei gravatar image

I partially solved the problem by not creating the RosTextView in main.xml but instead creating it in my MainActivity.java:

rosTextView = new RosTextView(this);

Is this the only way?

-Bei

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-11-23 08:09:16 -0500

Seen: 1,357 times

Last updated: Dec 29 '11