Arduino Accessory Mode library problem

Hellow All,

I have arduino mega adk. I'm trying to configure arduino sketch.

I downloaded library from

I use version1 in zip file.

i use following code for test

// accessory descriptor. It's how Arduino identifies itself to Android
char accessoryName[] = "Mega_ADK"; // your Arduino board
char companyName[] = "Arduino SA";

// led variables
int ledPin = 13;

// counters
long timer = millis();

// initialize the accessory:
AndroidAccessory usb(companyName, accessoryName);

void setup() {
  Serial.begin( 9600 );
  // start the connection to the device over the USB host:

  pinMode(ledPin, OUTPUT);   

void loop() {
  /* Print to usb */
  if(millis()-timer>100) { // sending 10 times per second
    if (usb.isConnected()) { // isConnected makes sure the USB connection is ope
      char val =;
      Serial.print( val );
      if( val == 'a' )
        digitalWrite( ledPin, HIGH );
      else if( val == 'b' )
        digitalWrite( ledPin, LOW );
    timer = millis();

but it gives me following error. Is this library old new for the codes im using ? How can i find correct libraries ?

C:\Users\cihan\AppData\Local\Temp\cc9mMbFm.ltrans0.ltrans.o: In function `__static_initialization_and_destruction_0':

C:\Users\cihan\Documents\Arduino\sketch_feb02b/sketch_feb02b.ino:29: undefined reference to `AndroidAccessory::AndroidAccessory(char const*, char const*, char const*, char const*, char const*, char const*)'

C:\Users\cihan\AppData\Local\Temp\cc9mMbFm.ltrans0.ltrans.o: In function `setup':

C:\Users\cihan\Documents\Arduino\sketch_feb02b/sketch_feb02b.ino:34: undefined reference to `AndroidAccessory::begin()'

C:\Users\cihan\AppData\Local\Temp\cc9mMbFm.ltrans0.ltrans.o: In function `loop':

C:\Users\cihan\Documents\Arduino\sketch_feb02b/sketch_feb02b.ino:42: undefined reference to `AndroidAccessory::isConnected()'

C:\Users\cihan\Documents\Arduino\sketch_feb02b/sketch_feb02b.ino:43: undefined reference to `AndroidAccessory::read()'

collect2.exe: error: ld returned 1 exit status

exit status 1 Error compiling for board Arduino Mega ADK.

I’m pretty sure you left a line off the code you posted:

#include <AndroidAccessory.h>

Which version of the Arduino IDE are you using?