Beginner Question

First, to set the stage:
Installed/Using:
Android Galaxy S3 Mini (4.1.2)/ Galaxy Nexus (4.2.2)
Mega-ADK 2560 R3
Arduino 1.0.5
Processing 2.09b
SDK Tools for android _r22.0.1 (and much much more)

I'm trying to upload the following code from a Tellart android+arduino+processing example tutorial. I know the example might not work but the trouble is I can't even get it compiled in the Arduino sketch.

////////////////////////////////////////////////////////////
//NEEDED FOR ALL ARDUINO ADK sketches
////////////////////////////////////////////////////////////
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

// accessory descriptor. It's how Arduino identifies itself to Android
char applicationName[] = "Mega_ADK"; // the app on your phone
char accessoryName[] = "Mega_ADK"; // your Arduino board
char companyName[] = "Freeware";

// make up anything you want for these
char versionNumber[] = "1.0";
char serialNumber[] = "1";
char url[] = "http://labs.arduino.cc/adk/"; // the URL of your app online


//initialize the accessory:
AndroidAccessory usb(companyName, applicationName,
accessoryName,versionNumber,url,serialNumber);
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////




// button variables
int redPin = A0; //analog 0
int greenPin = A1; //analog 1
int bluePin = A2; //analog 2
int redVal;
int greenVal;
int blueVal;

long timer = millis(); // counter to track last time we sent values


void setup() {
  usb.powerOn();  // start the connection to the device over the USB host:
}

void loop() {
  // Read the RGB Pots
  redVal = analogRead(redPin) /4;
  greenVal = analogRead(greenPin) /4;
  blueVal = analogRead(bluePin) /4;


  // Print to usb 
  if(millis() - timer > 100) { // Has it been over 100ms since last send?
    if (usb.isConnected()) { // isConnected makes sure the USB connection is open
      usb.beginTransmission();
      
      usb.write('R'); //SEND R for red, and the red value
      usb.write(redVal);
      
      usb.write('G');
      usb.write(greenVal);
      
      usb.write('B');
      usb.write(blueVal);
      
      usb.endTransmission();
    }
    timer = millis(); //reset the timer
  }
}

This is exactly how I have typed it in. My error reads the following:

RGB_arduino.ino: In function 'void loop()':
RGB_arduino:53: error: 'class AndroidAccessory' has no member named 'beginTransmission'
RGB_arduino:55: error: no matching function for call to 'AndroidAccessory::write(char)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:56: error: no matching function for call to 'AndroidAccessory::write(int&)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:58: error: no matching function for call to 'AndroidAccessory::write(char)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:59: error: no matching function for call to 'AndroidAccessory::write(int&)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:61: error: no matching function for call to 'AndroidAccessory::write(char)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:62: error: no matching function for call to 'AndroidAccessory::write(int&)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:64: error: 'class AndroidAccessory' has no member named 'endTransmission''

So my question is:
What is beginTransmission, why isn't it compiling? Am I missing files or do I need to alter libraries?

Do you have these?

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

Yes, I have those files, but only the most current releases I could find.

https://code.google.com/p/android/issues/detail?id=31568

This includes the usb.h and androidaccessory.h file I am currently using. I'm somewhat confused about the max3421e.h, as I read somewhere that it is already included into the Mega ADK board, not sure if that's relevant, I still have the downloaded library.

In which case check that you have not got a beginTransmission() have you typed in the right name, have you privided the right number and types of parameters.

Mark

Well, on further inspection I realized that the AndroidAccessory and USB_HOST 2.0 I downloaded were modified files from the original libraries linked on the tellart website.
After deleting my sketchbook libraries and replacing them with the linked files, I am able to compile and upload successfully.

Now for the communication to Android device:
The code I am using:

import cc.arduino.*;
ArduinoAdkUsb arduino;


//hold the color values
int rectcolor = color(0, 0, 0);
int redVal; 
int greenVal;
int blueVal;

void setup() {
  arduino = new ArduinoAdkUsb( this ); //init arduino

  if ( arduino.list() != null ) arduino.connect( arduino.list()[0] ); //if there is an arduino to connect to, do so
  
  orientation( PORTRAIT ); //Lock PORTRAIT view
}

void draw() {
  background( 255 );

  if ( arduino.isConnected() ) {
    
    if ( arduino.available() > 0 ) {
      
      
      //read a character from the serial (from arduino)
      char readByte = arduino.readChar();
      
      //If the character is R,G, or B the following character is the value. So read that and store it.

      
      if (readByte == 'R') {
        redVal = arduino.readByte() & 0xFF;
      }else if (readByte == 'G') {
        greenVal = arduino.readByte() & 0xFF;
      }else if (readByte == 'B') {
        blueVal = arduino.readByte() & 0xFF;
      }

      rectcolor = color(redVal, greenVal, blueVal);
    }
    
    fill( rectcolor ); //set fill color to the RGB values
    rect( 0,0, sketchWidth(), sketchHeight() ); //fill screen
  }

  connected();
}

void onStop() {
  finish();
}

void connected() {
  
  if ( arduino.isConnected() ){
    fill( 0, 255, 0 ); //on is green
  }else{
    fill( 255, 0, 0 ); //off is red
  }  
    
  ellipse( 16, 16, 30, 30 );
 
}

Returns the error:

Exception in thread "Thread-14" java.lang.NoSuchMethodError: cc.arduino.adk.processing.MyBuild.preprocess(Ljava/io/File;Ljava/lang/String;Lprocessing/mode/java/preproc/PdePreprocessor;)Ljava/lang/String;
	at cc.arduino.adk.processing.MyBuild.createProject(Unknown Source)
	at cc.arduino.adk.processing.MyBuild.build(Unknown Source)
	at cc.arduino.adk.processing.MyCompileThread.compileAndUpload(Unknown Source)
	at cc.arduino.adk.processing.MyCompileThread.run(Unknown Source)

This part of the forum deals with C/C++ for the arduino NOT .... You may wnat to try other parts of the site or other sites!

Mark