title: Phonegap plugin for android is not working. Why?
body: <p>I cannot make an Android phonegap plugin work. Not even a single one of the examples I found nor my pathetic failures trying to create one by myself. I first tried with Tutorials like <a href="http://phpmyweb.net/2011/09/14/creating-a-plugin-for-phonegap-1-0-android/" rel="nofollow">this one</a>. They don't work for me. I always end up with a <code>Cannot call method of undefined</code> error. </p>
  
  <p>So I tried something ready. Got <a href="https://github.com/isawred2/phonegap-android-plugin-tutorial" rel="nofollow">this project</a> from github. It's just a simple plugin to show a toast. I checked everything that i learned on the tutorials:</p>
  
  <pre><code>//the package name in the java
  package com.phonegap.toast;
  
  //my class extends Plugin and has a simple show toast method.
  
  public class Tutorial extends Plugin {
  @Override
  public PluginResult execute(String cmd, JSONArray args, String callback) {
      if(cmd.equals("toast"))
      {
          return showToast(args);
      }
      return null;
  }
  
  private PluginResult showToast(JSONArray args) {
      final String message;
      try {
          message = args.getString(0);
          ctx.runOnUiThread(new Runnable()
          {
              public void run() {
                  Toast myToast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
                  myToast.show();
              }
          });
  
          return new PluginResult(PluginResult.Status.OK);
      } catch (JSONException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
      }       
  }   
  
  }
  </code></pre>
  
  <p>the plugin is defined in res/xml/plugins.xml</p>
  
  <p><code>plugin name="Tutorial" value="com.phonegap.toast.Tutorial"</code></p>
  
  <p>and no, if i put it on rex/xml/config.xml it also doesn't work</p>
  
  <p>Last, the method that calls the plugin:</p>
  
  <pre><code>function createToast() {
    // i also tried window.Tutorial.showToast('Hello AndroidOpen'); with no success
    window.plugins.Tutorial.showToast('Hello AndroidOpen');
  }
  </code></pre>
  
  <p>And here I get the same error again.</p>
  
  <p><code>10-22 15:39:07.770: E/Web Console(2885): Uncaught TypeError: Cannot call method 'showToast' of undefined at file:///android_asset/www/main.js:123</code> </p>
  
  <p>Any enlightened soul can explain to me what I'm doing wrong? I've been trying this for days, with many different plugins, both my own and even <a href="https://github.com/phonegap/phonegap-plugins/tree/master/Android" rel="nofollow">this ones</a> and I can't find out what is it. </p>