when using the ab.jar in eclipse I get the following error when trying to run the bot.
“Could not find class ‘org.alicebot.ab.Bot’, referenced from method…”. The chat class is being imported but the bot class cannot be imported.
Here is my code:
import org.alicebot.ab.Bot;
import org.alicebot.ab.Chat;
import android.annotation.SuppressLint;
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
//import android.widget.ImageView;
//import android.widget.RelativeLayout;
public class MainActivity extends Activity {
String usertext; String response;
String botname="MAVIS";
Bot mavis=new Bot(botname);
Chat chat= new Chat(mavis);
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final LinearLayout ll1 = (LinearLayout) findViewById(R.id.ll1);
final LinearLayout ll2 = (LinearLayout) findViewById(R.id.ll2);
final ScrollView scv = (ScrollView) findViewById(R.id.sv);
final Button btn = (Button) findViewById(R.id.button1);
final EditText medit = (EditText) findViewById(R.id.editText1);
btn.setOnClickListener(new View.OnClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//ImageView imgu=new ImageView(v.getContext());
//ImageView imgb=new ImageView(v.getContext());
TextView tvu=new TextView(v.getContext());
TextView tvb=new TextView(v.getContext());
TextView tvut=new TextView(v.getContext());
TextView tvbt=new TextView(v.getContext());
TextView tvdivider1=new TextView(v.getContext());
TextView tvdivider2=new TextView(v.getContext());
final LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
//imgu.setLayoutParams(lparams);
//imgb.setLayoutParams(lparams);
tvu.setLayoutParams(lparams);
tvb.setLayoutParams(lparams);
tvut.setLayoutParams(lparams);
tvbt.setLayoutParams(lparams);
tvdivider1.setLayoutParams(lparams);
tvdivider2.setLayoutParams(lparams);
usertext = medit.getText().toString();
if(usertext.trim().length() != 0){
ll1.addView(tvu);
ll1.addView(tvb);
ll2.addView(tvut);
ll2.addView(tvbt);
ll1.addView(tvdivider1);
ll2.addView(tvdivider2);
//imgu.setImageResource(R.drawable.user);
//imgb.setImageResource(R.drawable.user);
response=chat.multisentenceRespond(usertext);
tvu.setText("User");
tvb.setText(botname);
tvbt.setText(" : "+ response);
tvut.setText(" : "+ usertext);
medit.setText(" ");
tvdivider1.setText(" ");
tvdivider2.setText(" --------------------");
}
else{
//do nothing
}
}
});
scv.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
scv.post(new Runnable() {
public void run() {
scv.fullScroll(View.FOCUS_DOWN);
}
});
}
});
}
}
I have imported the external library and defined the classpath for it. I have also copied the ab.jar in my project folder and even defined the classpath for it. But nothing seems to be working. Am I doing this wrong or are there more libraries that are needed for this to work. Anybody have a solution to my problem?