title: Facebook get authorize error on LoginDialogListener IllegalStateException: Could not execute method of the activity
body: <p>I´m using this code to put wall message in Facebook, but...not found the DialogListeners:</p>
  
  <p>This is the code of the activity.</p>
  
  <p>I´m use the tutorial: <a href="http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/" rel="nofollow">http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/</a></p>
  
  <pre><code>public class FacebookPostMessageActivity extends Activity {
    public class LoginDialogListener implements DialogListener {
      public void onComplete(Bundle values) {
        saveCredentials(facebook);
        if (messageToPost != null) {
          postToWall(messageToPost);
        }
      }
  
      public void onFacebookError(FacebookError error) {
        showToast("Authentication with Facebook failed!");
        finish();
      }
  
      public void onError(DialogError error) {
        showToast("Authentication with Facebook failed!");
        finish();
      }
  
      public void onCancel() {
        showToast("Authentication with Facebook cancelled!");
        finish();
      }
    }
  
    private static final String APP_ID = "xxxxxxxxxxxxxxxxx";
    private static final String[] PERMISSIONS = new String[] { "publish_stream" };
    private static final String TOKEN = "access_token";
    private static final String EXPIRES = "expires_in";
    private static final String KEY = "facebook-credentials";
    private Facebook facebook;
    private String messageToPost;
  
    public boolean saveCredentials(Facebook facebook) {
      Editor editor = getApplicationContext().getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
      editor.putString(TOKEN, facebook.getAccessToken());
      editor.putLong(EXPIRES, facebook.getAccessExpires());
      return editor.commit();
    }
  
    public boolean restoreCredentials(Facebook facebook) {
      SharedPreferences sharedPreferences = getApplicationContext()
          .getSharedPreferences(KEY, Context.MODE_PRIVATE);
      facebook.setAccessToken(sharedPreferences.getString(TOKEN, null));
      facebook.setAccessExpires(sharedPreferences.getLong(EXPIRES, 0));
      return facebook.isSessionValid();
    }
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      facebook = new Facebook(APP_ID);
      restoreCredentials(facebook);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.main);
      String facebookMessage = getIntent().getStringExtra("facebookMessage");
      if (facebookMessage == null) {
        facebookMessage = "Test wall post";
      }
      messageToPost = facebookMessage;
    }
  
    public void doNotShare(View button) {
      finish();
    }
  
    public void share(View button) {
      if (!facebook.isSessionValid()) {
        loginAndPostToWall();
      } else {
        postToWall(messageToPost);
      }
    }
  
    public void postToWall(String message) {
      FacebookPoster fp = new FacebookPoster();
      fp.execute(message, null, null);
    }
  
    private class FacebookPoster extends AsyncTask {
      protected void onPostExecute(String result) {
        showToast(result);
        finish();
      }
  
      @Override
      protected Object doInBackground(Object... params) {
        Bundle parameters = new Bundle();
        parameters.putString("message", messageToPost);
        parameters.putString("description", "topic share");
        try {
          facebook.request("me");
          String response = facebook.request("me/feed", parameters, "POST");
          Log.d("Tests", "got response: " + response);
          if (response == null || response.equals("") || response.equals("false")) {
            return "Blank response.";
          } else {
              return "Message posted to your facebook wall!";
          }
        } catch (Exception e) {
          Log.d("ShareOnFacebook", e.getMessage());
          return "Failed to post to wall!";
        }
      }
    }
  
    public void loginAndPostToWall() {
      facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());
    }
  
    private void showToast(String message) {
      Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
    }
  }
  </code></pre>
  
  <p>This is the log, I don´t see the dialog for auth my acount...directly i see "Force close":</p>
  
  <pre><code>07-24 15:47:19.252: E/AndroidRuntime(4937): FATAL EXCEPTION: main
  07-24 15:47:19.252: E/AndroidRuntime(4937): java.lang.IllegalStateException: Could not execute method of the activity
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.view.View$1.onClick(View.java:2168)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.view.View.performClick(View.java:2552)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.view.View$PerformClick.run(View.java:9229)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.os.Handler.handleCallback(Handler.java:587)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.os.Handler.dispatchMessage(Handler.java:92)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.os.Looper.loop(Looper.java:130)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.app.ActivityThread.main(ActivityThread.java:3701)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at java.lang.reflect.Method.invokeNative(Native Method)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at java.lang.reflect.Method.invoke(Method.java:507)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at dalvik.system.NativeStart.main(Native Method)
  07-24 15:47:19.252: E/AndroidRuntime(4937): Caused by: java.lang.reflect.InvocationTargetException
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at java.lang.reflect.Method.invokeNative(Native Method)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at java.lang.reflect.Method.invoke(Method.java:507)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.view.View$1.onClick(View.java:2163)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     ... 11 more
  07-24 15:47:19.252: E/AndroidRuntime(4937): Caused by: java.lang.NoClassDefFoundError: com.facebook.android.R$drawable
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at com.facebook.android.FbDialog.createCrossImage(FbDialog.java:106)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at com.facebook.android.FbDialog.onCreate(FbDialog.java:81)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.app.Dialog.dispatchOnCreate(Dialog.java:307)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at android.app.Dialog.show(Dialog.java:225)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at com.facebook.android.Facebook.dialog(Facebook.java:814)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at com.facebook.android.Facebook.startDialogAuth(Facebook.java:343)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at com.facebook.android.Facebook.authorize(Facebook.java:206)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at abm.face.post.FacebookPostMessageActivity.loginAndPostToWall(FacebookPostMessageActivity.java:144)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     at abm.face.post.FacebookPostMessageActivity.share(FacebookPostMessageActivity.java:98)
  07-24 15:47:19.252: E/AndroidRuntime(4937):     ... 14 more
  </code></pre>
  
  <p>My manifest, with the internet permissions:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="abm.face.post" android:versionCode="1" android:versionName="1.0" &gt;
      &lt;uses-sdk android:minSdkVersion="8" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name"&gt;
        &lt;activity android:name=".FacebookPostMessageActivity" android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;
            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
        &lt;/activity&gt;
      &lt;/application&gt;
    &lt;/manifest&gt;
  </code></pre>
  
  <p>any solution please??</p>