Fixing the ADK Library to work with Arduino 1.0

April 6, 2012

If you’ll try to create a sketch using the Android ADK library on  the latest version of Arduino (1.0 as of this writing), you will get several errors just like this:

Damn it I accidentally deleted the images!

This is because they renamed some header files and also changed the signature of some commonly used functions. Initially I thought it will take a while to figure this out but then in reality, you just need to modify some files which is not really a big deal.

First, let’s fix the Max3421e.h header file. For Mac, it is located in ~/Documents/Arduino/libraries/USB_Host_Shield/. Just open it and replace the line

#include "WProgram.h"


#include "Arduino.h"

and save it. Next, compile the sketch again and observe the error message on the console.

Damn it I accidentally deleted the images!

Which means AndroidAccessory.h is also referencing the header file WProgram.h which does not exist anymore.  AndroidAccessory.h is located in ~/Documents/Arduino/libraries/AndroidAccessory/. Let’s go and change that and compile. You will see that we now have a different error message:

Damn it I accidentally deleted the images!

There are a couple of things here, first, Max_LCD.h is also referencing to the missing-in-action WProgram.h. Let’s change that. You can find it in ~/Documents/Arduino/libraries/USB_Host_Shield/. Then there’s an error saying “conflicting return type specified for  ’virtual void Max_LCD::write(uint8_t)‘” at the bottom part of the image above. Let’s open the Max_LCD.h header file and notice that it extends the Print.h header file:

class Max_LCD : public Print {

Now let’s open Print.h. It is located in You will notice that the function write is now returning a size_t data type instead of void which is being expected by the extending class Max_LCD.h.

virtual size_t write(uint8_t) = 0;

Now let’s go back to Max_LCD.h and change the return type of the function write(). You will also need to change the implementation in the Max_LCD.cpp to reflect the changes in its header file. Also, Max_LCD.cpp is referencing to WProgram.h and let’s change that as well. After this, you will now have a happy compiler and a working ADK Sketch for Arduino 1.0.

Damn it I accidentally deleted the images!

comments powered by Disqus